Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Delegate #include? to #to_a.

  • Loading branch information...
commit 525daf3c8a0cdcb38136b785576e772faea97078 1 parent 2e0927f
@jnunemaker jnunemaker authored
Showing with 11 additions and 1 deletion.
  1. +1 −1  lib/plucky/query.rb
  2. +10 −0 test/plucky/test_query.rb
View
2  lib/plucky/query.rb
@@ -13,7 +13,7 @@ class Query
attr_reader :criteria, :options, :collection
def_delegator :criteria, :simple?
def_delegator :options, :fields?
- def_delegators :to_a, :each
+ def_delegators :to_a, :each, :include?
def initialize(collection, opts={})
@collection, @options, @criteria = collection, OptionsHash.new, CriteriaHash.new
View
10 test/plucky/test_query.rb
@@ -524,6 +524,16 @@ class QueryTest < Test::Unit::TestCase
end
end
+ context "#include?" do
+ should "be true if included" do
+ Query.new(@collection).include?(@john).should be(true)
+ end
+
+ should "be false if not included" do
+ Query.new(@collection).include?(['_id', 'frankyboy']).should be(false)
+ end
+ end
+
context "#to_a" do
should "return all documents the query matches" do
Query.new(@collection).sort(:name).to_a.
Please sign in to comment.
Something went wrong with that request. Please try again.