Skip to content

Commit

Permalink
NodeMixin#initialize yield self to block [#82 state:resolved]
Browse files Browse the repository at this point in the history
  • Loading branch information
jho406 authored and andreas committed Oct 6, 2009
1 parent 85f78b7 commit c4a2fea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/neo4j/mixins/node_mixin.rb
Expand Up @@ -35,6 +35,7 @@ def initialize(*args)
init_without_node
init_node(*args) if self.respond_to?(:init_node)
end
yield self if block_given?
# must call super with no arguments so that chaining of the initialize method works
super()
end
Expand Down
10 changes: 10 additions & 0 deletions test/neo4j/node_mixin_spec.rb
Expand Up @@ -77,6 +77,16 @@ class TestNode4
node2 = TestNode4.new(node1.internal_node)
node1.internal_node.should == node2.internal_node
end

it "should accept a block and pass self as parameter" do
class TestNode5
include Neo4j::NodeMixin
property :foo
end

node1 = TestNode5.new {|n| n.foo = 'hi'}
node1.foo.should == 'hi'
end
end


Expand Down

0 comments on commit c4a2fea

Please sign in to comment.