mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
2789b5d2ce
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1726 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
56 lines
1.4 KiB
Ruby
56 lines
1.4 KiB
Ruby
module ActionMailer
|
|
module AdvAttrAccessor #:nodoc:
|
|
def self.append_features(base)
|
|
super
|
|
base.extend(ClassMethods)
|
|
end
|
|
|
|
module ClassMethods #:nodoc:
|
|
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
|
|
|
|
module ActionMailer
|
|
module AdvAttrAccessor #:nodoc:
|
|
def self.append_features(base)
|
|
super
|
|
base.extend(ClassMethods)
|
|
end
|
|
|
|
module ClassMethods #:nodoc:
|
|
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
|