config/initializers/spree.rb in spree-0.8.5 vs config/initializers/spree.rb in spree-0.9.0
- old
+ new
@@ -27,17 +27,27 @@
# Add extra support goodies (similar to rails active support)
#class Array #:nodoc:
# include Spree::Support::CoreExtensions::Array
#end
-# Ryan Bates - http://railscasts.com/episodes/112
class ActiveRecord::Base
+ # Ryan Bates - http://railscasts.com/episodes/112
named_scope :conditions, lambda { |*args| {:conditions => args} }
+
+ # general merging of conditions, names following the searchlogic pattern
+ # conditions_all is a more descriptively named enhancement of the above
+ named_scope :conditions_all, lambda { |*args| {:conditions => [args].flatten} }
+
+ # forming the disjunction of a list of conditions (as strings)
+ named_scope :conditions_any, lambda { |*args|
+ args = [args].flatten
+ raise "non-strings in conditions_any" unless args.all? {|s| s.is_a? String}
+ { :conditions => args.map {|c| "(#{c})"}.join(" OR ") }
+ }
end
class String #:nodoc:
include Spree::Support::CoreExtensions::String
end
CalendarDateSelect.format = :american
-