Module: Fog::Attributes::ClassMethods
- Included in:
- Collection, Model
- Defined in:
- lib/fog/core/attributes.rb
Instance Method Summary collapse
- #_load(marshalled) ⇒ Object
- #aliases ⇒ Object
- #attribute(name, options = {}) ⇒ Object
- #attributes ⇒ Object
- #default_values ⇒ Object
- #identity(name, options = {}) ⇒ Object
- #ignore_attributes(*args) ⇒ Object
- #ignored_attributes ⇒ Object
Instance Method Details
#_load(marshalled) ⇒ Object
5 6 7 |
# File 'lib/fog/core/attributes.rb', line 5 def _load(marshalled) new(Marshal.load(marshalled)) end |
#aliases ⇒ Object
9 10 11 |
# File 'lib/fog/core/attributes.rb', line 9 def aliases @aliases ||= {} end |
#attribute(name, options = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/fog/core/attributes.rb', line 21 def attribute(name, = {}) type = .fetch(:type, 'default').to_s.capitalize default = .fetch(:default, false) Fog::Attributes::const_get(type).new(self, name, ).create attributes << name default_values[name] = default if default Array([:aliases]).each do |new_alias| aliases[new_alias] = name end end |
#attributes ⇒ Object
13 14 15 |
# File 'lib/fog/core/attributes.rb', line 13 def attributes @attributes ||= [] end |
#default_values ⇒ Object
17 18 19 |
# File 'lib/fog/core/attributes.rb', line 17 def default_values @default_values ||= {} end |
#identity(name, options = {}) ⇒ Object
32 33 34 35 |
# File 'lib/fog/core/attributes.rb', line 32 def identity(name, = {}) @identity = name self.attribute(name, ) end |
#ignore_attributes(*args) ⇒ Object
37 38 39 |
# File 'lib/fog/core/attributes.rb', line 37 def ignore_attributes(*args) @ignored_attributes = args.collect {|attr| attr.to_s } end |
#ignored_attributes ⇒ Object
41 42 43 |
# File 'lib/fog/core/attributes.rb', line 41 def ignored_attributes @ignored_attributes ||= [] end |