From a20d6b5d2040217f209a8bb0286a4ae5c2cf13d6 Mon Sep 17 00:00:00 2001 From: Jim Radford Date: Tue, 27 Nov 2012 16:08:58 -0800 Subject: [PATCH] Avoid removing trying to remove properties that don't exist --- lib/neography/property.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/neography/property.rb b/lib/neography/property.rb index 69cb24b..2315071 100644 --- a/lib/neography/property.rb +++ b/lib/neography/property.rb @@ -11,10 +11,12 @@ def []=(key, value) key = key.to_sym k_str = key.to_s if value.nil? - if self.is_a? Neography::Node - neo_server.remove_node_properties(self.neo_id, [k_str]) - else - neo_server.remove_relationship_properties(self.neo_id, [k_str]) + unless @table[key].nil? + if self.is_a? Neography::Node + neo_server.remove_node_properties(self.neo_id, [k_str]) + else + neo_server.remove_relationship_properties(self.neo_id, [k_str]) + end end else if self.is_a? Neography::Node @@ -33,7 +35,6 @@ def new_ostruct_member(name) meta = class << self; self; end meta.send(:define_method, name) { @table[name] } meta.send(:define_method, "#{name}=") do |value| - @table[name] = value self[name.to_sym] = value end end