Skip to content
Browse files

Change #freeze to only freeze the attributes.

Fixes #246.
  • Loading branch information...
1 parent 5f19820 commit 3209a706cc971741ca86588b43b3446c4d4288c4 @tylerhunt tylerhunt committed Nov 22, 2011
Showing with 14 additions and 2 deletions.
  1. +8 −2 ripple/lib/ripple/document/persistence.rb
  2. +6 −0 ripple/spec/ripple/persistence_spec.rb
View
10 ripple/lib/ripple/document/persistence.rb
@@ -86,9 +86,15 @@ def destroy
false
end
- # Freezes the document, preventing further modification.
+ # Freeze the attributes hash instead of the record itself to avoid
+ # errors when calling methods on frozen records.
def freeze
- @attributes.freeze; super
+ @attributes.freeze
+ end
+
+ # Returns +true+ if the attributes hash has been frozen.
+ def frozen?
+ @attributes.freeze
end
attr_writer :robject
View
6 ripple/spec/ripple/persistence_spec.rb
@@ -161,6 +161,12 @@
@widget.should be_frozen
end
+ it "should be able to call #errors after destroying" do
+ @widget.destroy.should be_true
+ @widget.should be_frozen
+ expect { @widget.errors }.to_not raise_error
+ end
+
it "should be a root document" do
@widget._root_document.should == @widget
end

0 comments on commit 3209a70

Please sign in to comment.
Something went wrong with that request. Please try again.