Permalink
Browse files

add object_id exception to Mash

  • Loading branch information...
1 parent 8ba3149 commit 2fa400b58956f3ae4c4eaaaa196084ffc659072f Steven Davidovitz committed Sep 4, 2012
Showing with 16 additions and 2 deletions.
  1. +4 −0 lib/hashie/mash.rb
  2. +12 −2 spec/hashie/mash_spec.rb
View
@@ -77,6 +77,10 @@ def type #:nodoc:
self["type"]
end
+ def object_id #:nodoc:
+ self["object_id"]
+ end
+
alias_method :regular_reader, :[]
alias_method :regular_writer, :[]=
@@ -97,6 +97,16 @@
@mash.author.should be_nil
end
+ it "should not call super if object_id is not a key" do
+ @mash.object_id.should == nil
+ end
+
+ it "should return the value if object_id is a key" do
+ @mash.object_id = "Steve"
+ @mash.object_id.should == "Steve"
+ end
+
+
it "should not call super if id is not a key" do
@mash.id.should == nil
end
@@ -291,11 +301,11 @@ class SubMash < Hashie::Mash
initial = Hashie::Mash.new(:name => 'randy', :address => {:state => 'TX'})
copy = Hashie::Mash.new(initial)
initial.name.should == copy.name
- initial.object_id.should_not == copy.object_id
+ initial.__id__.should_not == copy.__id__
copy.address.state.should == 'TX'
copy.address.state = 'MI'
initial.address.state.should == 'TX'
- copy.address.object_id.should_not == initial.address.object_id
+ copy.address.__id__.should_not == initial.address.__id__
end
it "should accept a default block" do

0 comments on commit 2fa400b

Please sign in to comment.