Module: Fog::Attributes::ClassMethods
- Included in:
- Collection, Model
- Defined in:
- lib/fog/core/attributes.rb
Instance Method Summary collapse
- #_load(marshalled) ⇒ Object
- #aliases ⇒ Object
- #associations ⇒ Object
-
#attribute(name, options = {}) ⇒ Object
Defines a new attribute.
- #attributes ⇒ Object
- #default_values ⇒ Object
- #has_many(name, collection_name, options = {}) ⇒ Object
- #has_many_identities(name, collection_name, options = {}) ⇒ Object
- #has_one(name, collection_name, options = {}) ⇒ Object
- #has_one_identity(name, collection_name, options = {}) ⇒ Object
- #identity(name, options = {}) ⇒ Object
- #ignore_attributes(*args) ⇒ Object
- #ignored_attributes ⇒ Object
- #masks ⇒ Object
Instance Method Details
#_load(marshalled) ⇒ Object
4 5 6 |
# File 'lib/fog/core/attributes.rb', line 4 def _load(marshalled) new(Marshal.load(marshalled)) end |
#aliases ⇒ Object
8 9 10 |
# File 'lib/fog/core/attributes.rb', line 8 def aliases @aliases ||= {} end |
#associations ⇒ Object
12 13 14 |
# File 'lib/fog/core/attributes.rb', line 12 def associations @associations ||= {} end |
#attribute(name, options = {}) ⇒ Object
Defines a new attribute
36 37 38 39 |
# File 'lib/fog/core/attributes.rb', line 36 def attribute(name, = {}) type = .fetch(:type, "default").to_s.capitalize Fog::Attributes.const_get(type).new(self, name, ) end |
#attributes ⇒ Object
16 17 18 |
# File 'lib/fog/core/attributes.rb', line 16 def attributes @attributes ||= [] end |
#default_values ⇒ Object
20 21 22 |
# File 'lib/fog/core/attributes.rb', line 20 def default_values @default_values ||= {} end |
#has_many(name, collection_name, options = {}) ⇒ Object
45 46 47 |
# File 'lib/fog/core/attributes.rb', line 45 def has_many(name, collection_name, = {}) Fog::Associations::ManyModels.new(self, name, collection_name, ) end |
#has_many_identities(name, collection_name, options = {}) ⇒ Object
53 54 55 |
# File 'lib/fog/core/attributes.rb', line 53 def has_many_identities(name, collection_name, = {}) Fog::Associations::ManyIdentities.new(self, name, collection_name, ) end |
#has_one(name, collection_name, options = {}) ⇒ Object
41 42 43 |
# File 'lib/fog/core/attributes.rb', line 41 def has_one(name, collection_name, = {}) Fog::Associations::OneModel.new(self, name, collection_name, ) end |
#has_one_identity(name, collection_name, options = {}) ⇒ Object
49 50 51 |
# File 'lib/fog/core/attributes.rb', line 49 def has_one_identity(name, collection_name, = {}) Fog::Associations::OneIdentity.new(self, name, collection_name, ) end |
#identity(name, options = {}) ⇒ Object
57 58 59 60 |
# File 'lib/fog/core/attributes.rb', line 57 def identity(name, = {}) @identity = name attribute(name, ) end |
#ignore_attributes(*args) ⇒ Object
62 63 64 |
# File 'lib/fog/core/attributes.rb', line 62 def ignore_attributes(*args) @ignored_attributes = args.map(&:to_s) end |
#ignored_attributes ⇒ Object
66 67 68 |
# File 'lib/fog/core/attributes.rb', line 66 def ignored_attributes @ignored_attributes ||= [] end |
#masks ⇒ Object
24 25 26 |
# File 'lib/fog/core/attributes.rb', line 24 def masks @masks ||= {} end |