Class: Fog::Associations::Default
- Inherits:
-
Object
- Object
- Fog::Associations::Default
- Defined in:
- lib/fog/core/associations/default.rb
Overview
Fog Default Association
This class has the shared behavior between all association models.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#aliases ⇒ Object
readonly
Returns the value of attribute aliases.
-
#as ⇒ Object
readonly
Returns the value of attribute as.
-
#association_class ⇒ Object
readonly
Returns the value of attribute association_class.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #create_aliases ⇒ Object
- #create_mask ⇒ Object
-
#initialize(model, name, collection_name, options) ⇒ Default
constructor
A new instance of Default.
Constructor Details
#initialize(model, name, collection_name, options) ⇒ Default
Returns a new instance of Default.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/fog/core/associations/default.rb', line 9 def initialize(model, name, collection_name, ) @model = model @name = name model.associations[name] = collection_name @aliases = .fetch(:aliases, []) @as = .fetch(:as, name) @association_class = .fetch(:association_class, Fog::Association) create_setter create_getter create_aliases create_mask end |
Instance Attribute Details
#aliases ⇒ Object (readonly)
Returns the value of attribute aliases.
7 8 9 |
# File 'lib/fog/core/associations/default.rb', line 7 def aliases @aliases end |
#as ⇒ Object (readonly)
Returns the value of attribute as.
7 8 9 |
# File 'lib/fog/core/associations/default.rb', line 7 def as @as end |
#association_class ⇒ Object (readonly)
Returns the value of attribute association_class.
7 8 9 |
# File 'lib/fog/core/associations/default.rb', line 7 def association_class @association_class end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
7 8 9 |
# File 'lib/fog/core/associations/default.rb', line 7 def model @model end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/fog/core/associations/default.rb', line 7 def name @name end |
Instance Method Details
#create_aliases ⇒ Object
22 23 24 25 26 |
# File 'lib/fog/core/associations/default.rb', line 22 def create_aliases Array(aliases).each do |alias_name| model.aliases[alias_name] = name end end |
#create_mask ⇒ Object
28 29 30 |
# File 'lib/fog/core/associations/default.rb', line 28 def create_mask model.masks[name] = as end |