class ActiveForce::Association::AbstractProjectionBuilder

Attributes

association[R]
parent_association_field[R]

Public Class Methods

new(association, parent_association_field = nil) click to toggle source
# File lib/active_force/association/eager_load_projection_builder.rb, line 35
def initialize(association, parent_association_field = nil)
  @association = association
  @parent_association_field = parent_association_field
end

Public Instance Methods

apply_association_scope(query) click to toggle source
# File lib/active_force/association/eager_load_projection_builder.rb, line 44
def apply_association_scope(query)
  return query unless association.scoped?
  raise InvalidEagerLoadAssociation, "Cannot use scopes that expect arguments: #{association.relation_name}" if association.scoped_as.arity.positive?

  query.instance_exec(&association.scoped_as)
end
projections() click to toggle source
# File lib/active_force/association/eager_load_projection_builder.rb, line 40
def projections
  raise "Must define #{self.class.name}#projections"
end
query_with_association_fields() click to toggle source

Use ActiveForce::Query to build a subquery for the SFDC relationship name. Per SFDC convention, the name needs to be pluralized

# File lib/active_force/association/eager_load_projection_builder.rb, line 55
def query_with_association_fields
  relationship_name = association.sfdc_association_field
  query = ActiveQuery.new(association.relation_model, relationship_name)
  query.fields association.relation_model.fields
  apply_association_scope(query)
end