Skip to content

Commit

Permalink
fixed issue where setting a previously undefined property using dot n…
Browse files Browse the repository at this point in the history
…otation has no effect on the DB
  • Loading branch information
Dan authored and Dan committed Apr 5, 2012
1 parent a66922f commit 5e02630
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
8 changes: 6 additions & 2 deletions lib/neography/property.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,13 @@ def new_ostruct_member(name)
end


def self.method_missing(method_sym, *arguments, &block)
if (method_sym.to_s =~ /$=/) != nil
def method_missing(method_sym, *arguments, &block)
if (method_sym.to_s =~ /=$/) != nil
new_ostruct_member(method_sym.to_s.chomp("="))

# We just defined the getter/setter above, but we haven't actually
# applied them yet.
self.send(method_sym, *arguments)
else
super
end
Expand Down
11 changes: 10 additions & 1 deletion spec/integration/node_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
existing_node.eyes.should == "brown"
end

it "can change a node's properties that does not already exist" do
it "can change a node's properties that does not already exist using []=" do
new_node = Neography::Node.create("weight" => 150, "eyes" => "green")

new_node.weight = 200
Expand All @@ -149,6 +149,15 @@
existing_node.hair.should == "black"
end

it "can change a node's properties that does not already exist" do
new_node = Neography::Node.create

new_node.hair = "black"

existing_node = Neography::Node.load(new_node)
existing_node.hair.should == "black"
end

it "can pass issue 18" do
n = Neography::Node.create("name" => "Test")
n.prop = 1
Expand Down

0 comments on commit 5e02630

Please sign in to comment.