Class: Vault::Associations::HasManyProxy

Inherits:
Scoping::Scope show all
Defined in:
lib/vault/associations.rb

Instance Attribute Summary

Attributes inherited from Scoping::Scope

#conditions, #model

Instance Method Summary collapse

Methods inherited from Scoping::Scope

#method_missing, #respond_to?, #store

Methods included from Finders

#[], #all

Constructor Details

#initialize(owner, model, foreign_key, conditions = {}) ⇒ HasManyProxy

Returns a new instance of HasManyProxy.



26
27
28
29
30
# File 'lib/vault/associations.rb', line 26

def initialize(owner, model, foreign_key, conditions={})
  super(model, conditions)
  @owner = owner
  @foreign_key = foreign_key
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Vault::Scoping::Scope

Instance Method Details

#<<(object) ⇒ Object



32
33
34
35
36
# File 'lib/vault/associations.rb', line 32

def <<(object)
  object.send("#{@foreign_key}=", @owner.key)
  object.save
  self
end