Browse files

should not convert the type of Hashie::Mashes childs to Hashie::Mash

  • Loading branch information...
1 parent 867adeb commit 84af9f334ad9e6e4eb98ae71835ecc2954540260 @andrehjr andrehjr committed with Michael Bleigh Dec 24, 2009
Showing with 10 additions and 1 deletion.
  1. +1 −1 lib/hashie/mash.rb
  2. +9 −0 spec/hashie/mash_spec.rb
View
2 lib/hashie/mash.rb
@@ -141,7 +141,7 @@ def convert_value(val, duping=false) #:nodoc:
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
View
9 spec/hashie/mash_spec.rb
@@ -74,6 +74,15 @@
@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"})

0 comments on commit 84af9f3

Please sign in to comment.