lib/mongomodel/support/scope/query_methods.rb in mongomodel-0.5.5 vs lib/mongomodel/support/scope/query_methods.rb in mongomodel-0.5.6

- old
+ new

@@ -3,31 +3,31 @@ module QueryMethods def initialize(*) SINGLE_VALUE_METHODS.each { |m| instance_variable_set("@#{m}_value", nil) } MULTI_VALUE_METHODS.each { |m| instance_variable_set("@#{m}_values", []) } end - + MULTI_VALUE_METHODS.each do |query_method| attr_accessor :"#{query_method}_values" - + class_eval <<-CEVAL, __FILE__ def #{query_method}(*args, &block) new_scope = clone value = Array.wrap(args.flatten).reject { |x| x.blank? } new_scope.#{query_method}_values += value if value.present? new_scope end - + def #{query_method}!(*args, &block) new_scope = clone value = Array.wrap(args.flatten).reject { |x| x.blank? } new_scope.#{query_method}_values = value new_scope end CEVAL end - + SINGLE_VALUE_METHODS.each do |query_method| attr_accessor :"#{query_method}_value" class_eval <<-CEVAL, __FILE__ def #{query_method}(value, &block) @@ -35,16 +35,16 @@ new_scope.#{query_method}_value = value new_scope end CEVAL end - + def from(value, &block) new_scope = clone new_scope.from_value = InstrumentedCollection.new(value.is_a?(String) ? klass.database.collection(value) : value) new_scope end - + def reverse_order if order_values.empty? order(:id.desc) else except(:order).order(MongoOrder.parse(order_values).reverse.to_a)