2005-05-29 12:36:22 -04:00
|
|
|
module ActionMailer
|
2005-07-06 04:22:56 -04:00
|
|
|
module AdvAttrAccessor #:nodoc:
|
2005-05-29 12:36:22 -04:00
|
|
|
def self.append_features(base)
|
|
|
|
super
|
|
|
|
base.extend(ClassMethods)
|
|
|
|
end
|
|
|
|
|
2005-07-06 04:22:56 -04:00
|
|
|
module ClassMethods #:nodoc:
|
2005-05-29 12:36:22 -04:00
|
|
|
def adv_attr_accessor(*names)
|
|
|
|
names.each do |name|
|
|
|
|
define_method("#{name}=") do |value|
|
|
|
|
instance_variable_set("@#{name}", value)
|
|
|
|
end
|
|
|
|
|
|
|
|
define_method(name) do |*parameters|
|
|
|
|
raise ArgumentError, "expected 0 or 1 parameters" unless parameters.length <= 1
|
|
|
|
if parameters.empty?
|
|
|
|
instance_variable_get("@#{name}")
|
|
|
|
else
|
|
|
|
instance_variable_set("@#{name}", parameters.first)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2005-07-06 04:22:56 -04:00
|
|
|
|
2005-05-29 12:36:22 -04:00
|
|
|
module ActionMailer
|
2005-07-06 04:22:56 -04:00
|
|
|
module AdvAttrAccessor #:nodoc:
|
2005-05-29 12:36:22 -04:00
|
|
|
def self.append_features(base)
|
|
|
|
super
|
|
|
|
base.extend(ClassMethods)
|
|
|
|
end
|
|
|
|
|
2005-07-06 04:22:56 -04:00
|
|
|
module ClassMethods #:nodoc:
|
2005-05-29 12:36:22 -04:00
|
|
|
def adv_attr_accessor(*names)
|
|
|
|
names.each do |name|
|
|
|
|
define_method("#{name}=") do |value|
|
|
|
|
instance_variable_set("@#{name}", value)
|
|
|
|
end
|
|
|
|
|
|
|
|
define_method(name) do |*parameters|
|
|
|
|
raise ArgumentError, "expected 0 or 1 parameters" unless parameters.length <= 1
|
|
|
|
if parameters.empty?
|
|
|
|
instance_variable_get("@#{name}")
|
|
|
|
else
|
|
|
|
instance_variable_set("@#{name}", parameters.first)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|