lib/searchlogic/named_scopes/or_conditions.rb in searchlogic-2.3.9 vs lib/searchlogic/named_scopes/or_conditions.rb in searchlogic-2.3.10

- old
+ new

@@ -8,10 +8,14 @@ def condition?(name) # :nodoc: super || or_condition?(name) end + def named_scope_options(name) # :nodoc: + super || super(or_conditions(name).join("_or_")) + end + private def or_condition?(name) !or_conditions(name).nil? end @@ -104,18 +108,22 @@ klass = klass.klass if details = klass.send(:association_condition_details, part, last_condition) 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 { :path => path, :column => part, :condition => last_condition } end def create_or_condition(scopes, args) - named_scope scopes.join("_or_"), lambda { |*args| + scopes_options = scopes.collect { |scope, *args| send(scope, *args).proxy_options } + # We're using first scope to determine column's type + scope = named_scope_options(scopes.first) + column_type = scope.respond_to?(:searchlogic_arg_type) ? scope.searchlogic_arg_type : :string + named_scope scopes.join("_or_"), searchlogic_lambda(column_type) { |*args| merge_scopes_with_or(scopes.collect { |scope| [scope, *args] }) } end def merge_scopes_with_or(scopes)