Skip to content

Commit

Permalink
remove conditional that could sometimes instance_eval on current_obje…
Browse files Browse the repository at this point in the history
…ct when passing a block with no args to #attribute
  • Loading branch information
lafave committed Feb 19, 2013
1 parent 7d4438e commit d0bfbd8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/bldr/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/fixtures/nested_objects.json.bldr
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit d0bfbd8

Please sign in to comment.