Sha256: d8edd7b09f769489d00363bea4156174d92e6f332caa461c5bfc8ab93a316273

Contents?: true

Size: 812 Bytes

Versions: 55

Compression:

Stored size: 812 Bytes

Contents

module ThinkingSphinx
  class Join
    attr_accessor :source, :column, :associations
    
    def initialize(source, column)
      @source = source
      @column = column
      
      @associations = association_stack(column.__path.clone).each { |assoc|
        assoc.join_to(source.base)
      }
      
      source.joins << self
    end
    
    private
    
    # Gets a stack of associations for a specific path.
    # 
    def association_stack(path, parent = nil)
      assocs = []
      
      if parent.nil?
        assocs = @source.association(path.shift)
      else
        assocs = parent.children(path.shift)
      end
      
      until path.empty?
        point  = path.shift
        assocs = assocs.collect { |assoc| assoc.children(point) }.flatten
      end
      
      assocs
    end
  end
end

Version data entries

55 entries across 55 versions & 7 rubygems

Version Path
thinking-sphinx-2.0.9 lib/thinking_sphinx/join.rb
thinking-sphinx-1.4.9 lib/thinking_sphinx/join.rb
thinking-sphinx-2.0.8 lib/thinking_sphinx/join.rb
thinking-sphinx-1.4.8 lib/thinking_sphinx/join.rb
thinking-sphinx-2.0.7 lib/thinking_sphinx/join.rb
thinking-sphinx-1.4.7 lib/thinking_sphinx/join.rb
thinking-sphinx-2.0.5 lib/thinking_sphinx/join.rb
thinking-sphinx-1.4.6 lib/thinking_sphinx/join.rb
sayso-thinking-sphinx-2.0.3.002 lib/thinking_sphinx/join.rb
sayso-thinking-sphinx-2.0.3.001 lib/thinking_sphinx/join.rb
thinking-sphinx-2.0.4 lib/thinking_sphinx/join.rb
thinking-sphinx-1.4.5 lib/thinking_sphinx/join.rb
thinking-sphinx-2.0.3 lib/thinking_sphinx/join.rb
thinking-sphinx-1.4.4 lib/thinking_sphinx/join.rb
thinking-sphinx-1.4.3 lib/thinking_sphinx/join.rb
thinking-sphinx-2.0.2 lib/thinking_sphinx/join.rb
thinking-sphinx-1.4.2 lib/thinking_sphinx/join.rb
thinking-sphinx-1.4.1 lib/thinking_sphinx/join.rb
joshcutler-thinking-sphinx-1.3.18 lib/thinking_sphinx/join.rb
thinking-sphinx-2.0.1 lib/thinking_sphinx/join.rb