Class: ActiveForce::Association::HasManyAssociationProjectionBuilder

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

Instance Attribute Summary

Attributes inherited from AbstractProjectionBuilder

#association

Instance Method Summary collapse

Methods inherited from AbstractProjectionBuilder

#initialize

Constructor Details

This class inherits a constructor from ActiveForce::Association::AbstractProjectionBuilder

Instance Method Details

#projectionsObject

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



42
43
44
45
46
47
48
49
# File 'lib/active_force/association/eager_load_projection_builder.rb', line 42

def projections
  match = association.sfdc_association_field.match /__r\z/
  # pluralize the table name, and append '__r' if it was there to begin with
  relationship_name = association.sfdc_association_field.sub(match.to_s, '').pluralize + match.to_s
  query = Query.new relationship_name
  query.fields association.relation_model.fields
  ["(#{query.to_s})"]
end