Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixing errors after refactoring ScopeReflection
- Loading branch information
James Vanneman
committed
Mar 20, 2013
1 parent
3f1ebba
commit 49d127d
Showing
13 changed files
with
112 additions
and
95 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
53 changes: 0 additions & 53 deletions
53
lib/searchlogic/active_record_ext/scopes/conditions/or/condition_reflection.rb
This file was deleted.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
lib/searchlogic/active_record_ext/scopes/conditions/or/methods_constructor.rb
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,35 @@ | ||
module Searchlogic | ||
module ActiveRecordExt | ||
module Scopes | ||
module Conditions | ||
class MethodConstructor | ||
attr_reader :method_name, :method_parts | ||
def initialize(method_name) | ||
@method_name = method_name | ||
@method_parts = method_name.to_s.split(/_or_(?!equal)/) | ||
end | ||
|
||
def methods_array | ||
method_parts.map { |m| add_condition(m) } | ||
end | ||
|
||
private | ||
|
||
def ending_alias_condition | ||
@ending_alias_condition ||= ScopeReflection.new(method_name).predicate | ||
end | ||
|
||
def add_condition(method) | ||
return method if /(_any|_all)$/ =~ method | ||
if ScopeReflection.authorized?(method) | ||
grouping = /(_any|_all)$/.match(ending_alias_condition) | ||
grouping.nil? ? method : method + grouping | ||
else | ||
method + ending_alias_condition | ||
end | ||
end | ||
end | ||
end | ||
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
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
10 changes: 10 additions & 0 deletions
10
lib/searchlogic/scope_reflection_ext/uninitialized_class_error.rb
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,10 @@ | ||
module Searchlogic | ||
module ScopeReflectionExt | ||
class UninitializedClassError < StandardError | ||
def initialize | ||
msg = "You must initialize ScopeReflection with a class in order to call this method" | ||
super(msg) | ||
end | ||
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
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