From 52ab1909b6906363427013556eae0a9761dd930b Mon Sep 17 00:00:00 2001 From: fitz Date: Sat, 14 Jul 2012 13:11:52 +0200 Subject: [PATCH] making a clone of _decl_props --- lib/neo4j/rails/attributes.rb | 3 ++- spec/integration/model_spec.rb | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/neo4j/rails/attributes.rb b/lib/neo4j/rails/attributes.rb index 70c17a148..bc24946cd 100644 --- a/lib/neo4j/rails/attributes.rb +++ b/lib/neo4j/rails/attributes.rb @@ -240,7 +240,8 @@ module ClassMethods # Returns all defined properties def columns columns = [] - self._decl_props.each { |k,v| v.store(:name, k ); columns << Column.new(v) } + props = Marshal.load( Marshal.dump(self._decl_props )) + props.each { |k,v| v.store(:name, k ); columns << Column.new(v) } columns end diff --git a/spec/integration/model_spec.rb b/spec/integration/model_spec.rb index 6e420978b..945aa4735 100644 --- a/spec/integration/model_spec.rb +++ b/spec/integration/model_spec.rb @@ -742,6 +742,16 @@ def to_s columns.map { |c| c.index }.should include("exact") columns.map { |c| c.index }.should_not include("fulltext") end + + it "should not update the models _decl_props hash" do + a_model = create_model do + property :foo, :index => :exact, :type => String + end + a_model.columns + a_model._decl_props.should == {:foo=>{:index=>:exact, :converter=>Neo4j::TypeConverters::StringConverter, :type=>String}} + end + + end end