Module: Attributes::ClassMethods
- Included in:
- Fog::Collection, Fog::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
4 5 6 |
# File 'lib/fog/attributes.rb', line 4 def _load(marshalled) new(Marshal.load(marshalled)) end |
#aliases ⇒ Object
8 9 10 |
# File 'lib/fog/attributes.rb', line 8 def aliases @aliases ||= {} end |
#attribute(name, other_names = []) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/fog/attributes.rb', line 16 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
12 13 14 |
# File 'lib/fog/attributes.rb', line 12 def attributes @attributes ||= [] end |
#identity(name, other_names = []) ⇒ Object
27 28 29 30 |
# File 'lib/fog/attributes.rb', line 27 def identity(name, other_names = []) @identity = name self.attribute(name, other_names) end |