lib/searchlogic/named_scopes/conditions.rb in binarylogic-searchlogic-2.1.12 vs lib/searchlogic/named_scopes/conditions.rb in binarylogic-searchlogic-2.1.13

- old
+ new

@@ -26,10 +26,11 @@ :empty => [] } CONDITIONS = {} + # Add any / all variations to every comparison and wildcard condition COMPARISON_CONDITIONS.merge(WILDCARD_CONDITIONS).each do |condition, aliases| CONDITIONS[condition] = aliases CONDITIONS["#{condition}_any".to_sym] = aliases.collect { |a| "#{a}_any".to_sym } CONDITIONS["#{condition}_all".to_sym] = aliases.collect { |a| "#{a}_all".to_sym } end @@ -45,11 +46,11 @@ # # This method will return: # # :conditions => {:column => value} # - # ActiveRecord hides this internally, so we have to try and pull it out with this + # ActiveRecord hides this internally in a Proc, so we have to try and pull it out with this # method. def named_scope_options(name) key = scopes.key?(name.to_sym) ? name.to_sym : primary_condition_name(name) if key @@ -66,10 +67,11 @@ # User.named_scope :age_is_4, :conditions => {:age => 4} # User.search(:age_is_4 => false) == User.all # User.search(:age_is_4 => true) == User.all(:conditions => {:age => 4}) # # We also use it when trying to "copy" the underlying named scope for association - # conditions. + # conditions. This way our aliased scope accepts the same number of parameters for + # the underlying scope. def named_scope_arity(name) options = named_scope_options(name) options.respond_to?(:arity) ? options.arity : nil end