Skip to content

Commit

Permalink
Delegate #include? to #to_a.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnunemaker committed Jun 17, 2010
1 parent 2e0927f commit 525daf3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/plucky/query.rb
Expand Up @@ -13,7 +13,7 @@ class Query
attr_reader :criteria, :options, :collection attr_reader :criteria, :options, :collection
def_delegator :criteria, :simple? def_delegator :criteria, :simple?
def_delegator :options, :fields? def_delegator :options, :fields?
def_delegators :to_a, :each def_delegators :to_a, :each, :include?


def initialize(collection, opts={}) def initialize(collection, opts={})
@collection, @options, @criteria = collection, OptionsHash.new, CriteriaHash.new @collection, @options, @criteria = collection, OptionsHash.new, CriteriaHash.new
Expand Down
10 changes: 10 additions & 0 deletions test/plucky/test_query.rb
Expand Up @@ -524,6 +524,16 @@ class QueryTest < Test::Unit::TestCase
end end
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 context "#to_a" do
should "return all documents the query matches" do should "return all documents the query matches" do
Query.new(@collection).sort(:name).to_a. Query.new(@collection).sort(:name).to_a.
Expand Down

0 comments on commit 525daf3

Please sign in to comment.