Skip to content

Commit

Permalink
Added pop modifier instance method (Dave Krupinski)
Browse files Browse the repository at this point in the history
  • Loading branch information
jnunemaker committed Mar 26, 2010
1 parent 878592a commit 0e7e6b0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/mongo_mapper/plugins/modifiers.rb
Expand Up @@ -81,6 +81,10 @@ def pull(hash)
def push_uniq(hash)
self.class.push_uniq({:_id => id}, hash)
end

def pop(hash)
self.class.pop({:_id => id}, hash)
end
end
end
end
Expand Down
10 changes: 9 additions & 1 deletion test/functional/test_modifiers.rb
Expand Up @@ -317,6 +317,14 @@ def assert_page_counts(page, day_count, week_count, month_count)
page2.reload
page.tags.should == %w(foo)
end
end

should "be able to pop with modifier hashes" do
page = @page_class.create(:tags => %w(foo bar))

page.pop({:tags => 1})

page.reload
page.tags.should == %w(foo)
end
end
end

0 comments on commit 0e7e6b0

Please sign in to comment.