Module: Autostruct::Receive
Instance Method Summary collapse
Instance Method Details
#receive(parameters) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/autostruct/receive.rb', line 3 def receive(parameters) parameters.each_pair do |attr, value| instance_variable_set("@#{attr}", value) define_singleton_method :"#{attr}" do instance_variable_get("@#{attr}") end define_singleton_method :"#{attr}=" do |new_value| instance_variable_set("@#{attr}", new_value) end end end |