def build(associations, parent = nil)
parent ||= @joins.last
case associations
when Symbol, String
reflection = parent.reflections[associations.to_s.intern] or
raise ConfigurationError, "Association named '#{ associations }' was not found; perhaps you misspelled it?"
@reflections << reflection
@joins << JoinAssociation.new(reflection, self, parent)
when Array
associations.each do |association|
build(association, parent)
end
when Hash
associations.keys.sort{|a,b|a.to_s<=>b.to_s}.each do |name|
build(name, parent)
build(associations[name])
end
else
raise ConfigurationError, associations.inspect
end
end