Module: ActionMailer::AdvAttrAccessor::ClassMethods
- Defined in:
- lib/action_mailer/adv_attr_accessor.rb
Overview
:nodoc:
Instance Method Summary collapse
Instance Method Details
#adv_attr_accessor(*names) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/action_mailer/adv_attr_accessor.rb', line 8 def adv_attr_accessor(*names) names.each do |name| ivar = "@#{name}" define_method("#{name}=") do |value| instance_variable_set(ivar, value) end define_method(name) do |*parameters| raise ArgumentError, "expected 0 or 1 parameters" unless parameters.length <= 1 if parameters.empty? if instance_variable_names.include?(ivar) instance_variable_get(ivar) end else instance_variable_set(ivar, parameters.first) end end end end |