method
construct
v3.2.8 -
Show latest stable
- Class:
ActiveRecord::Associations::JoinDependency
construct(parent, associations, join_parts, row)protected
No documentation available.
# File activerecord/lib/active_record/associations/join_dependency.rb, line 155
def construct(parent, associations, join_parts, row)
case associations
when Symbol, String
name = associations.to_s
join_part = join_parts.detect { |j|
j.reflection.name.to_s == name &&
j.parent_table_name == parent.class.table_name }
raise(ConfigurationError, "No such association") unless join_part
join_parts.delete(join_part)
construct_association(parent, join_part, row)
when Array
associations.each do |association|
construct(parent, association, join_parts, row)
end
when Hash
associations.sort_by { |k,_| k.to_s }.each do |association_name, assoc|
association = construct(parent, association_name, join_parts, row)
construct(association, assoc, join_parts, row) if association
end
else
raise ConfigurationError, associations.inspect
end
end