Skip to content

Commit

Permalink
Merge branch 'master' of github.com:maxdemarzi/neography
Browse files Browse the repository at this point in the history
  • Loading branch information
maxdemarzi committed Apr 14, 2012
2 parents d230abf + 40c0fe0 commit 46fbfdf
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
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
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 46fbfdf

Please sign in to comment.