Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Some cleanup in finder options.

  • Loading branch information...
commit b18b761b67d10ed2b07941a078742cb1b662980c 1 parent b35509b
@jnunemaker jnunemaker authored
Showing with 5 additions and 9 deletions.
  1. +5 −9 lib/mongo_mapper/finder_options.rb
View
14 lib/mongo_mapper/finder_options.rb
@@ -14,8 +14,7 @@ class FinderOptions
def initialize(model, options)
raise ArgumentError, "Options must be a hash" unless options.is_a?(Hash)
- options = options.clone
- options.symbolize_keys!
+ options = options.symbolize_keys
@model = model
@options = {}
@@ -41,12 +40,10 @@ def criteria
# @return [Hash] Mongo compatible options
def options
- options = @options.dup
-
- fields = options.delete(:fields) || options.delete(:select)
- skip = options.delete(:skip) || options.delete(:offset) || 0
- limit = options.delete(:limit) || 0
- sort = options.delete(:sort) || convert_order_to_sort(options.delete(:order))
+ fields = @options.delete(:fields) || @options.delete(:select)
+ skip = @options.delete(:skip) || @options.delete(:offset) || 0
+ limit = @options.delete(:limit) || 0
+ sort = @options.delete(:sort) || convert_order_to_sort(@options.delete(:order))
{:fields => to_mongo_fields(fields), :skip => skip.to_i, :limit => limit.to_i, :sort => sort}
end
@@ -74,7 +71,6 @@ def to_mongo_criteria(conditions, parent_key=nil)
case value
when Array
- operator_present = field.to_s =~ /^\$/
criteria[field] = operator?(field) ? value : {'$in' => value}
when Hash
criteria[field] = to_mongo_criteria(value, field)
Please sign in to comment.
Something went wrong with that request. Please try again.