Skip to content

Commit

Permalink
Use set! method internally
Browse files Browse the repository at this point in the history
  • Loading branch information
dhh committed Dec 1, 2011
1 parent 2cf5761 commit 6564a5b
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lib/jbuilder.rb
Expand Up @@ -124,7 +124,7 @@ def method_missing(method, *args)
# json.age 32
# { "age": 32 }
when args.one?
_assign method, args.first
set! method, args.first

# json.comments { |json| ... }
# { "comments": ... }
Expand All @@ -143,17 +143,13 @@ def method_missing(method, *args)
end
end

def _assign(key, value)
@attributes[key] = value
end

# Overwrite in subclasses if you need to add initialization values
def _new_instance
__class__.new
end

def _yield_nesting(container)
@attributes[container] = _new_instance._tap { |jbuilder| yield jbuilder }.attributes!
set! container, _new_instance._tap { |jbuilder| yield jbuilder }.attributes!
end

def _inline_nesting(container, collection, attributes)
Expand Down

0 comments on commit 6564a5b

Please sign in to comment.