Class: Locomotive::Steam::Models::HasManyAssociation

Inherits:
ReferencedAssociation show all
Defined in:
lib/locomotive/steam/models/associations/has_many.rb

Instance Attribute Summary

Attributes inherited from ReferencedAssociation

#repository

Instance Method Summary collapse

Methods inherited from ReferencedAssociation

#__attach__, #__call_block_once__, #__name__, #__serialize__, #initialize, #method_missing

Constructor Details

This class inherits a constructor from Locomotive::Steam::Models::ReferencedAssociation

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Locomotive::Steam::Models::ReferencedAssociation

Instance Method Details

#__load__Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/locomotive/steam/models/associations/has_many.rb', line 6

def __load__
  key = :"#{@options[:inverse_of]}_id"

  # all the further queries will be scoped by the "foreign_key"
  @repository.local_conditions[key] = @entity._id

  # use order_by from options as the default one for further queries
  @repository.local_conditions[:order_by] = @options[:order_by] unless @options[:order_by].blank?

  # all the further calls (method_missing) will be delegated to @repository
  @repository
end