diff options
author | Rainux Luo <rainux@gmail.com> | 2010-09-08 00:13:01 +0800 |
---|---|---|
committer | Rainux Luo <rainux@gmail.com> | 2010-09-08 00:13:01 +0800 |
commit | 853f79aaafa3ec901b18e7ee18318bde61073b4f (patch) | |
tree | fce5885542152174c55fdc724ceee3939b3bccce | |
parent | 540f4bb9299fe168809330d5e350b5e7e17c4b2d (diff) | |
download | hashie-853f79aaafa3ec901b18e7ee18318bde61073b4f.tar.gz |
Mash#delete now works with Symbol key
-rw-r--r-- | lib/hashie/mash.rb | 4 | ||||
-rw-r--r-- | spec/hashie/mash_spec.rb | 14 |
2 files changed, 18 insertions, 0 deletions
diff --git a/lib/hashie/mash.rb b/lib/hashie/mash.rb index 97af028..f3d90f1 100644 --- a/lib/hashie/mash.rb +++ b/lib/hashie/mash.rb @@ -85,6 +85,10 @@ module Hashie regular_reader(ck) end + def delete(key) + super(convert_key(key)) + end + alias_method :regular_dup, :dup # Duplicates the current mash as a new mash. def dup diff --git a/spec/hashie/mash_spec.rb b/spec/hashie/mash_spec.rb index 5aa8818..eed1189 100644 --- a/spec/hashie/mash_spec.rb +++ b/spec/hashie/mash_spec.rb @@ -128,6 +128,20 @@ describe Hashie::Mash do duped.details.email.should be_nil end end + + describe 'delete' do + it 'should delete with String key' do + subject.delete('details') + subject.details.should be_nil + subject.should_not be_respond_to :details + end + + it 'should delete with Symbol key' do + subject.delete(:details) + subject.details.should be_nil + subject.should_not be_respond_to :details + end + end end it "should convert hash assignments into Hashie::Mashes" do |