summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandrehjr <andrehjr@gmail.com>2009-12-24 06:33:38 +0800
committerMichael Bleigh <michael@intridea.com>2010-01-14 07:14:24 +0800
commit84af9f334ad9e6e4eb98ae71835ecc2954540260 (patch)
tree5eeca2bda89cdb8cf1f6c49b9907f6640d8746e4
parent867adeb899a088e74e6127731519396437270394 (diff)
downloadhashie-84af9f334ad9e6e4eb98ae71835ecc2954540260.tar.gz
should not convert the type of Hashie::Mashes childs to Hashie::Mash
-rw-r--r--lib/hashie/mash.rb2
-rw-r--r--spec/hashie/mash_spec.rb9
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"})