diff --git a/lib/bldr/node.rb b/lib/bldr/node.rb index 0bb3cf7..2ebfe0a 100644 --- a/lib/bldr/node.rb +++ b/lib/bldr/node.rb @@ -204,7 +204,7 @@ def attribute(*args,&block) if block_given? raise(ArgumentError, "You may only pass one argument to #attribute when using the block syntax.") if args.size > 1 raise(ArgumentError, "You cannot use a block of arity > 0 if current_object is not present.") if block.arity > 0 and current_object.nil? - merge_result!(args.first, (block.arity == 1) ? block.call(current_object) : current_object.instance_eval(&block)) + merge_result! args.first, block.call(current_object) else case args.size when 1 # inferred object diff --git a/spec/fixtures/nested_objects.json.bldr b/spec/fixtures/nested_objects.json.bldr index f2bddc9..66ff38e 100644 --- a/spec/fixtures/nested_objects.json.bldr +++ b/spec/fixtures/nested_objects.json.bldr @@ -1,8 +1,8 @@ object :person => bert do attributes :name, :age - attribute :name_age do - "#{name} #{age}" + attribute :name_age do |person| + "#{person.name} #{person.age}" end object :friend => ernie do