-
Notifications
You must be signed in to change notification settings - Fork 469
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
70 changed files
with
676 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
appraise 'rails_3_2' do | ||
gem 'rails', '~> 3.2.21' | ||
gem 'rails', '~> 3.2.22.2' | ||
end | ||
|
||
appraise 'rails_4_0' do | ||
gem 'rails', '~> 4.0.12' | ||
gem 'rails', '~> 4.0.13' | ||
end | ||
|
||
appraise 'rails_4_1' do | ||
gem 'rails', '~> 4.1.8' | ||
gem 'rails', '~> 4.1.15' | ||
end | ||
|
||
appraise 'rails_4_2' do | ||
gem 'rails', '~> 4.2.0' | ||
gem 'rails', '~> 4.2.6' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
class ThinkingSphinx::ActiveRecord::SourceJoins | ||
def self.call(model, source) | ||
new(model, source).call | ||
end | ||
|
||
def initialize(model, source) | ||
@model, @source = model, source | ||
end | ||
|
||
def call | ||
append_specified_associations | ||
append_property_associations | ||
|
||
joins | ||
end | ||
|
||
private | ||
|
||
attr_reader :model, :source | ||
|
||
def append_property_associations | ||
source.properties.collect(&:columns).each do |columns| | ||
columns.each { |column| append_column_associations column } | ||
end | ||
end | ||
|
||
def append_column_associations(column) | ||
return if column.__stack.empty? | ||
|
||
joins.add_join_to column.__stack if column_exists?(column) | ||
end | ||
|
||
def append_specified_associations | ||
source.associations.reject(&:string?).each do |association| | ||
joins.add_join_to association.stack | ||
end | ||
end | ||
|
||
def column_exists?(column) | ||
Joiner::Path.new(model, column.__stack).model | ||
true | ||
rescue Joiner::AssociationNotFound | ||
false | ||
end | ||
|
||
def joins | ||
@joins ||= begin | ||
joins = Joiner::Joins.new model | ||
if joins.respond_to?(:join_association_class) | ||
joins.join_association_class = ThinkingSphinx::ActiveRecord::JoinAssociation | ||
end | ||
joins | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.