Module: ActiveRemote::Attributes
- Included in:
- Base
- Defined in:
- lib/active_remote/attributes.rb
Instance Method Summary collapse
-
#read_attribute(name) ⇒ Object
(also: #[])
Read attribute from the attributes hash.
-
#write_attribute(name, value) ⇒ Object
(also: #[]=)
Update an attribute in the attributes hash.
Instance Method Details
#read_attribute(name) ⇒ Object Also known as: []
Read attribute from the attributes hash
5 6 7 8 9 10 11 12 13 |
# File 'lib/active_remote/attributes.rb', line 5 def read_attribute(name) name = name.to_s if respond_to? name attribute(name) else raise ActiveAttr::UnknownAttributeError, "unknown attribute: #{name}" end end |
#write_attribute(name, value) ⇒ Object Also known as: []=
Update an attribute in the attributes hash
18 19 20 21 22 23 24 25 26 |
# File 'lib/active_remote/attributes.rb', line 18 def write_attribute(name, value) name = name.to_s if respond_to? "#{name}=" __send__("attribute=", name, value) else raise ActiveAttr::UnknownAttributeError, "unknown attribute: #{name}" end end |