Class: Fog::Associations::Default

Inherits:
Object
  • Object
show all
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

ManyIdentities, ManyModels, OneIdentity, OneModel

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options)
  @model = model
  @name = name
  model.associations[name] = collection_name
  @aliases = options.fetch(:aliases, [])
  @as = options.fetch(:as, name)
  @association_class = options.fetch(:association_class, Fog::Association)
  create_setter
  create_getter
  create_aliases
  create_mask
end

Instance Attribute Details

#aliasesObject (readonly)

Returns the value of attribute aliases.



7
8
9
# File 'lib/fog/core/associations/default.rb', line 7

def aliases
  @aliases
end

#asObject (readonly)

Returns the value of attribute as.



7
8
9
# File 'lib/fog/core/associations/default.rb', line 7

def as
  @as
end

#association_classObject (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

#modelObject (readonly)

Returns the value of attribute model.



7
8
9
# File 'lib/fog/core/associations/default.rb', line 7

def model
  @model
end

#nameObject (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_aliasesObject



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_maskObject



28
29
30
# File 'lib/fog/core/associations/default.rb', line 28

def create_mask
  model.masks[name] = as
end