Module: Recliner::AttributeMethods::Write
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/recliner/attribute_methods/write.rb
Instance Method Summary collapse
-
#[]=(name, value) ⇒ Object
Updates the attribute identified by
name
with the specifiedvalue
. -
#write_attribute(name, value) ⇒ Object
Updates the attribute identified by
name
with the specifiedvalue
.
Instance Method Details
#[]=(name, value) ⇒ Object
Updates the attribute identified by name
with the specified value
. (Alias for the protected write_attribute method).
24 25 26 |
# File 'lib/recliner/attribute_methods/write.rb', line 24 def []=(name, value) write_attribute(name, value) end |
#write_attribute(name, value) ⇒ Object
Updates the attribute identified by name
with the specified value
. Values are typecast to the appropriate type determined by the property.
12 13 14 15 16 17 18 19 20 |
# File 'lib/recliner/attribute_methods/write.rb', line 12 def write_attribute(name, value) if prop = property(name) attributes[prop.as] = prop.type_cast(value) else attributes[name.to_s] = value end value end |