Skip to content

Commit

Permalink
Merge pull request #70 from radford/avoid-nil-remove
Browse files Browse the repository at this point in the history
Avoid trying to remove properties that don't exist now that errors are thrown/checked
  • Loading branch information
maxdemarzi committed Nov 28, 2012
2 parents a9687eb + a20d6b5 commit 14d469e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/neography/property.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 14d469e

Please sign in to comment.