Class Criteria::Join
In: lib/join.rb
Parent: TableAlias

Methods

includes   new   table_alias  

Included Modules

Filterable

Attributes

parent  [R] 
reflection  [R] 
table_alias  [RW] 

Public Class methods

[Source]

    # File lib/join.rb, line 14
14:     def initialize(attribute, parent)
15:       @reflection = attribute
16:       @query = parent.query
17:       @parent = parent            
18:       association_reflection = parent.model_class.reflect_on_association(attribute.intern)
19: 
20:       # if we cannot reflect on the attribute, raise an exception
21:       raise "#{attribute} is not a relationship on class #{parent.model_class}" unless association_reflection
22: 
23:       # if this is a polymorphic has_one or has_many association, raise an error as AR cannot support that
24:       raise "Eager loading for the has_one or has_many side of a polymorphic association cannot be supported by ActiveRecord" if association_reflection.options.include? :polymorphic
25:       
26:       @model_class = association_reflection.klass
27:     
28:       # build the alias for this join - need to take into account all other joins that 
29:       # have been defined for the query because of the AR aliasing scheme
30:       @alias = @query.join_alias(self)
31:     end

Public Instance methods

[Source]

    # File lib/join.rb, line 33
33:     def includes
34:       return reflection.intern unless @joins and not @joins.empty?
35:       return {reflection.intern=>[@joins.collect {|j| j.includes}]}
36:     end

[Source]

    # File lib/join.rb, line 38
38:     def table_alias
39:       self
40:     end

[Validate]