lib/baby_squeel/association.rb
# Intelligently constructs Arel nodes. There are three outcomes:
#
# 1. The user explicitly constructed their join using #on.
#    See BabySqueel::Table#_arel.
#
#        Post.joining { author.on(author_id == author.id) }
#
# 2. The user aliased an implicitly joined association. ActiveRecord's
#    join dependency gives us no way of handling this, so we have to
#    throw an error.
#
#        Post.joining { author.as('some_alias') }
#
# 3. The user implicitly joined this association, so we pass this
#    association up the tree until it hits the top-level BabySqueel::Table.
#    Once it gets there, Arel join nodes will be constructed.
#
#        Post.joining { author }
#
Intelligently constructs Arel nodes. There are three outcomes:
1. The user explicitly constructed their join using #on.



2. The user aliased an implicitly joined association. ActiveRecord's
join dependency gives us no way of handling this, so we have to
throw an error.



3. The user implicitly joined this association, so we pass this
association up the tree until it hits the top-level BabySqueel::Table.
Once it gets there, Arel join nodes will be constructed.


Intelligently constructs Arel nodes . There are three outcomes : 1 . The user explicitly constructed their join using #on . 2 . The user aliased an implicitly joined association . ActiveRecord ' s join dependency gives us no way of handling this so we have to throw an error . 3 . The user implicitly joined this association so we pass this association up the tree until it hits the top - level BabySqueel :: Table . Once it gets there Arel join nodes will be constructed .
def _arel(associations = [])
      if _on
        super
      elsif alias?
        raise AssociationAliasingError.new(_reflection.name, _table.right)
      elsif _reflection.polymorphic? && _polymorphic_klass.nil?
        raise PolymorphicNotSpecifiedError.new(_reflection.name)
      else
        @parent._arel([self, *associations])
      end
    end
def _arel ( associations = [ ] ) if _on super elsif alias? raise AssociationAliasingError . new ( _reflection . name , _table . right ) elsif _reflection . polymorphic? && _polymorphic_klass . nil? raise PolymorphicNotSpecifiedError . new ( _reflection . name ) else @parent . _arel ( [ self , * associations ] ) end end
Intelligently constructs Arel nodes.
Intelligently constructs Arel nodes .
associations