diff options
-rw-r--r-- | lib/hashie/mash.rb | 2 | ||||
-rw-r--r-- | spec/hashie/mash_spec.rb | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/lib/hashie/mash.rb b/lib/hashie/mash.rb index 65222b1..69df491 100644 --- a/lib/hashie/mash.rb +++ b/lib/hashie/mash.rb @@ -141,7 +141,7 @@ module Hashie case val when ::Hash val = val.dup if duping - Hashie::Mash.new(val) + self.class.new(val) when Array val.collect{ |e| convert_value(e) } else diff --git a/spec/hashie/mash_spec.rb b/spec/hashie/mash_spec.rb index 7adbe6c..7078353 100644 --- a/spec/hashie/mash_spec.rb +++ b/spec/hashie/mash_spec.rb @@ -74,6 +74,15 @@ describe Hashie::Mash do @mash.details.address.state.should == 'TX' end + it "should not convert the type of Hashie::Mashes childs to Hashie::Mash" do + class MyMash < Hashie::Mash + end + + record = MyMash.new + record.son = MyMash.new + record.son.class.should == MyMash + end + context "#initialize" do it "should convert an existing hash to a Hashie::Mash" do converted = Hashie::Mash.new({:abc => 123, :name => "Bob"}) |