Module: Subjoin::Attributable
Overview
Generically handle arbitrary object attributes
Instance Attribute Summary collapse
-
#attributes ⇒ Hash
readonly
The object’s attributes.
Instance Method Summary collapse
-
#[](name) ⇒ Object
Access an attribute by property name.
-
#load_attributes(data) ⇒ Object
Load the object’s attributes.
Instance Attribute Details
#attributes ⇒ Hash (readonly)
The object’s attributes
8 9 10 |
# File 'lib/subjoin/attributable.rb', line 8 def attributes @attributes end |
Instance Method Details
#[](name) ⇒ Object
Access an attribute by property name
20 21 22 23 24 25 26 |
# File 'lib/subjoin/attributable.rb', line 20 def [](name) name = name.to_s if @attributes.has_key?(name) return @attributes[name] end return nil end |
#load_attributes(data) ⇒ Object
Load the object’s attributes
12 13 14 |
# File 'lib/subjoin/attributable.rb', line 12 def load_attributes(data) @attributes = data end |