Class: ActiveForce::Association::EagerLoadProjectionBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/active_force/association/eager_load_projection_builder.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(association, parent_association_field = nil, query_fields = nil) ⇒ EagerLoadProjectionBuilder

Returns a new instance of EagerLoadProjectionBuilder.



20
21
22
23
24
# File 'lib/active_force/association/eager_load_projection_builder.rb', line 20

def initialize(association, parent_association_field = nil, query_fields = nil)
  @association = association
  @parent_association_field = parent_association_field
  @query_fields = query_fields
end

Instance Attribute Details

#associationObject (readonly)

Returns the value of attribute association.



18
19
20
# File 'lib/active_force/association/eager_load_projection_builder.rb', line 18

def association
  @association
end

#parent_association_fieldObject (readonly)

Returns the value of attribute parent_association_field.



18
19
20
# File 'lib/active_force/association/eager_load_projection_builder.rb', line 18

def parent_association_field
  @parent_association_field
end

#query_fieldsObject (readonly)

Returns the value of attribute query_fields.



18
19
20
# File 'lib/active_force/association/eager_load_projection_builder.rb', line 18

def query_fields
  @query_fields
end

Class Method Details

.build(association, parent_association_field = nil, query_fields = nil) ⇒ Object



6
7
8
# File 'lib/active_force/association/eager_load_projection_builder.rb', line 6

def build(association, parent_association_field = nil, query_fields = nil)
  new(association, parent_association_field, query_fields).projections
end

.projection_builder_class(association) ⇒ Object



10
11
12
13
14
15
# File 'lib/active_force/association/eager_load_projection_builder.rb', line 10

def projection_builder_class(association)
  klass = association.class.name.demodulize
  ActiveForce::Association.const_get "#{klass}ProjectionBuilder"
rescue NameError
  raise "No projection builder exists for #{klass}"
end

Instance Method Details

#projectionsObject



26
27
28
29
# File 'lib/active_force/association/eager_load_projection_builder.rb', line 26

def projections
  builder_class = self.class.projection_builder_class(association)
  builder_class.new(association, parent_association_field, query_fields).projections
end