From 853f79aaafa3ec901b18e7ee18318bde61073b4f Mon Sep 17 00:00:00 2001 From: Rainux Luo Date: Wed, 8 Sep 2010 00:13:01 +0800 Subject: Mash#delete now works with Symbol key --- lib/hashie/mash.rb | 4 ++++ spec/hashie/mash_spec.rb | 14 ++++++++++++++ 2 files changed, 18 insertions(+) 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 -- cgit v1.2.1