Permalink
Browse files

added push_all and pull_all modifiers to documents

  • Loading branch information...
hamin committed Apr 14, 2011
1 parent ca68e6c commit 2d20223a45f17101aa1f104def666d71caa7f424
Showing with 24 additions and 0 deletions.
  1. +8 −0 lib/mongo_mapper/plugins/modifiers.rb
  2. +16 −0 test/functional/test_modifiers.rb
@@ -95,10 +95,18 @@ def set(hash)
def push(hash)
self.class.push(id, hash)
end
def push_all(hash)
self.class.push_all(id, hash)
end
def pull(hash)
self.class.pull(id, hash)
end
def pull_all(hash)
self.class.pull_all(id, hash)
end
def add_to_set(hash)
self.class.push_uniq(id, hash)
@@ -368,6 +368,14 @@ def assert_keys_removed(page, *keys)
page.reload
page.tags.should == %w(foo)
end
should "be able to push_all with modifier hashes" do
page = @page_class.create
page.push_all(:tags => %w(foo bar))
page.reload
page.tags.should == %w(foo bar)
end
should "be able to pull with criteria and modifier hashes" do
page = @page_class.create(:tags => %w(foo bar))
@@ -376,6 +384,14 @@ def assert_keys_removed(page, *keys)
page.reload
page.tags.should == %w(bar)
end
should "be able to pull_all with criteria and modifier hashes" do
page = @page_class.create(:tags => %w(foo bar baz))
page.pull(:tags => %w(foo bar))
page.reload
page.tags.should == %w(baz)
end
should "be able to add_to_set with criteria and modifier hash" do
page = @page_class.create(:tags => 'foo')

0 comments on commit 2d20223

Please sign in to comment.