Permalink
Browse files

Clean up condition_details method by removing code path that never fires

  • Loading branch information...
1 parent 1e6fcf6 commit 1e3d192bc1712713df59fec2f38c236856126d56 @vandrijevik vandrijevik committed with Dec 8, 2009
Showing with 6 additions and 8 deletions.
  1. +5 −7 lib/searchlogic/named_scopes/conditions.rb
  2. +1 −1 lib/searchlogic/named_scopes/or_conditions.rb
View
12 lib/searchlogic/named_scopes/conditions.rb
@@ -89,13 +89,11 @@ def method_missing(name, *args, &block)
end
end
- def condition_details(name, *args)
- if args.size > 0 and !args.first.nil?
- assoc = reflect_on_association(args.first.to_sym)
- klass = assoc.klass
- name.to_s =~ /^(#{klass.column_names.join("|")})_(#{(PRIMARY_CONDITIONS + ALIAS_CONDITIONS).join("|")})$/
- {:column => $1, :condition => $2}
- elsif name.to_s =~ /^(#{column_names.join("|")})_(#{(PRIMARY_CONDITIONS + ALIAS_CONDITIONS).join("|")})$/
+ def condition_details(method_name)
+ column_name_matcher = column_names.join("|")
+ conditions_matcher = (PRIMARY_CONDITIONS + ALIAS_CONDITIONS).join("|")
+
+ if method_name.to_s =~ /^(#{column_name_matcher})_(#{conditions_matcher})$/
{:column => $1, :condition => $2}
end
end
View
2 lib/searchlogic/named_scopes/or_conditions.rb
@@ -106,7 +106,7 @@ def full_association_path(part, last_condition, given_assoc)
path << details[:association]
part = details[:condition]
given_assoc = details[:association]
- elsif details = klass.send(:condition_details, part, nil)
+ elsif details = klass.send(:condition_details, part)
return { :path => path, :column => details[:column], :condition => details[:condition] }
end
end

0 comments on commit 1e3d192

Please sign in to comment.