Module: Fog::Attributes::ClassMethods
- Included in:
- Collection, Model
- Defined in:
- lib/fog/attributes.rb
Instance Method Summary collapse
- #_load(marshalled) ⇒ Object
- #aliases ⇒ Object
- #attribute(name, other_names = []) ⇒ Object
- #attributes ⇒ Object
- #identity(name, other_names = []) ⇒ Object
Instance Method Details
#_load(marshalled) ⇒ Object
5 6 7 |
# File 'lib/fog/attributes.rb', line 5 def _load(marshalled) new(Marshal.load(marshalled)) end |
#aliases ⇒ Object
9 10 11 |
# File 'lib/fog/attributes.rb', line 9 def aliases @aliases ||= {} end |
#attribute(name, other_names = []) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/fog/attributes.rb', line 17 def attribute(name, other_names = []) class_eval <<-EOS, __FILE__, __LINE__ attr_accessor :#{name} EOS @attributes ||= [] @attributes |= [name] for other_name in [*other_names] aliases[other_name] = name end end |
#attributes ⇒ Object
13 14 15 |
# File 'lib/fog/attributes.rb', line 13 def attributes @attributes ||= [] end |
#identity(name, other_names = []) ⇒ Object
28 29 30 31 |
# File 'lib/fog/attributes.rb', line 28 def identity(name, other_names = []) @identity = name self.attribute(name, other_names) end |