Module: MyJohnDeere::JSONAttributes::ClassMethods
- Defined in:
- lib/myjohndeere/json_attributes.rb
Instance Attribute Summary collapse
-
#json_attributes ⇒ Object
Returns the value of attribute json_attributes.
Instance Method Summary collapse
Instance Attribute Details
#json_attributes ⇒ Object
Returns the value of attribute json_attributes.
4 5 6 |
# File 'lib/myjohndeere/json_attributes.rb', line 4 def json_attributes @json_attributes end |
Instance Method Details
#attributes_to_pull_from_json(*attribs) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/myjohndeere/json_attributes.rb', line 5 def attributes_to_pull_from_json(*attribs) self.json_attributes = attribs self.json_attributes.each do |attribute| attribute = attribute.to_s.underscore define_method("#{attribute}=") do |val| instance_variable_set("@#{attribute}", val) end define_method(attribute) do return instance_variable_get("@#{attribute}") end end end |