Module: FulfilApi::Resource::AttributeAssignable
- Included in:
- FulfilApi::Resource
- Defined in:
- lib/fulfil_api/resource/attribute_assignable.rb
Overview
The AttributeAssignable module provides a set of helper
methods to assign and cast attributes (including their values) to a {FulfilApi::Resource}.
Instance Method Summary collapse
-
#assign_attribute(name, value) ⇒ Hash
Assigns and casts a single attribute for the FulfilApi::Resource.
-
#assign_attributes(attributes) ⇒ Hash
Assigns and casts a set of attributes for the FulfilApi::Resource.
Instance Method Details
#assign_attribute(name, value) ⇒ Hash
Assigns and casts a single attribute for the FulfilApi::Resource.
25 26 27 28 29 30 |
# File 'lib/fulfil_api/resource/attribute_assignable.rb', line 25 def assign_attribute(name, value) attribute = build_attribute(name, value) attribute.deep_stringify_keys! @attributes = @attributes.deep_merge(attribute) end |
#assign_attributes(attributes) ⇒ Hash
Assigns and casts a set of attributes for the FulfilApi::Resource
12 13 14 15 16 17 18 |
# File 'lib/fulfil_api/resource/attribute_assignable.rb', line 12 def assign_attributes(attributes) attributes.each_pair do |key, value| assign_attribute(key, value) end @attributes end |