Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Instance variables over methods in query

  • Loading branch information...
commit f38802de61a8e11cc8c224fae544c31f2ce6e773 1 parent 204e49a
@jnunemaker jnunemaker authored
Showing with 12 additions and 12 deletions.
  1. +12 −12 lib/plucky/query.rb
View
24 lib/plucky/query.rb
@@ -17,8 +17,8 @@ class Query
attr_reader :criteria, :options, :collection
- def_delegator :criteria, :simple?
- def_delegator :options, :fields?
+ def_delegator :@criteria, :simple?
+ def_delegator :@options, :fields?
def_delegators :to_a, :include?
def initialize(collection, query_options = {})
@@ -33,8 +33,8 @@ def initialize_copy(original)
end
def object_ids(*keys)
- return criteria.object_ids if keys.empty?
- criteria.object_ids = *keys
+ return @criteria.object_ids if keys.empty?
+ @criteria.object_ids = *keys
self
end
@@ -171,8 +171,8 @@ def empty?
count.zero?
end
- def exists?(options={})
- !count(options).zero?
+ def exists?(query_options={})
+ !count(query_options).zero?
end
alias :exist? :exists?
@@ -205,8 +205,8 @@ def []=(key, value)
end
def merge(other)
- merged_criteria = criteria.merge(other.criteria).to_hash
- merged_options = options.merge(other.options).to_hash
+ merged_criteria = @criteria.merge(other.criteria).to_hash
+ merged_options = @options.merge(other.options).to_hash
clone.amend(merged_criteria).amend(merged_options)
end
@@ -215,7 +215,7 @@ def to_hash
end
def explain
- collection.find(criteria_hash, options_hash).explain
+ @collection.find(criteria_hash, options_hash).explain
end
def inspect
@@ -226,15 +226,15 @@ def inspect
end
def criteria_hash
- criteria.to_hash
+ @criteria.to_hash
end
def options_hash
- options.to_hash
+ @options.to_hash
end
def cursor
- collection.find(criteria_hash, options_hash)
+ @collection.find(criteria_hash, options_hash)
end
private
Please sign in to comment.
Something went wrong with that request. Please try again.