diff --git a/lib/strokedb/document.rb b/lib/strokedb/document.rb index aa3815a2..bbb5c359 100644 --- a/lib/strokedb/document.rb +++ b/lib/strokedb/document.rb @@ -269,7 +269,7 @@ def diff(from) def pretty_print #:nodoc: slots = to_raw.except('meta') - s = is_a?(ImmutableDocument) ? "#<(imm)" : "#<" + s = is_a?(ImmutableDocument) ? "#<^" : "#<" Util.catch_circular_reference(self) do if self[:meta] && name = meta[:name] @@ -745,5 +745,9 @@ def mutable? def save! self end + + def make_mutable! + unextend(ImmutableDocument) + end end end \ No newline at end of file diff --git a/spec/lib/strokedb/document/document_spec.rb b/spec/lib/strokedb/document/document_spec.rb index c19fa10e..bc1cb4f1 100644 --- a/spec/lib/strokedb/document/document_spec.rb +++ b/spec/lib/strokedb/document/document_spec.rb @@ -821,6 +821,23 @@ @document.should_not == @another_document end +end + +describe "Immutable Document" do + + before(:each) do + setup_default_store + @document = Document.new(:some_data => 1).make_immutable! + @document.should_not be_mutable + end + + it "should be able to be mutable again" do + @document.make_mutable! + @document.should be_mutable + end + + + end describe "Valid Document's JSON" do