Skip to content

Commit

Permalink
fixing issue 18
Browse files Browse the repository at this point in the history
  • Loading branch information
maxdemarzi committed Jan 2, 2012
1 parent 88e697c commit 485807c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/neography/property.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,18 @@ def []=(key, value)
if value.nil?
if self.is_a? Neography::Node
neo_server.remove_node_properties(self.neo_id, [key])
@table[key] = nil
else
neo_server.remove_relationship_properties(self.neo_id, [key])
@table[key] = nil
end
else
if self.is_a? Neography::Node
neo_server.set_node_properties(self.neo_id, {k => value})
else
neo_server.set_relationship_properties(self.neo_id, {k => value})
end

new_ostruct_member(k) unless self.respond_to?(key)

end
@table[key] = value
end


Expand All @@ -40,6 +37,7 @@ def new_ostruct_member(name)
self[name.to_sym] = x
end
end
name
end


Expand Down
17 changes: 17 additions & 0 deletions spec/integration/node_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,23 @@
existing_node.eyes.should == "brown"
existing_node.hair.should == "black"
end

it "can pass issue 18" do
n = Neography::Node.create("name" => "Test")
n.prop = 1
n.prop.should == 1
n.prop = 1
n.prop.should == 1
n[:prop].should == 1
n[:prop2] = 2
n[:prop2].should == 2
n[:prop2] = 2
n[:prop2].should == 2
n.name
n.name = "New Name"
n.name.should == "New Name"
end

end

describe "get node properties" do
Expand Down

0 comments on commit 485807c

Please sign in to comment.