Skip to content

Commit b7b5abb

Browse files
committed
Stop mutating options in partial! method
1 parent 7e16adf commit b7b5abb

File tree

1 file changed

+3
-23
lines changed

1 file changed

+3
-23
lines changed

lib/jbuilder/jbuilder_template.rb

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ def partial!(*args)
5555
if args.one? && _is_active_model?(args.first)
5656
_render_active_model_partial args.first
5757
else
58-
_render_explicit_partial(*args)
58+
options = args.extract_options!.dup
59+
options[:partial] = args.first if args.present?
60+
_render_partial_with_options options
5961
end
6062
end
6163

@@ -248,28 +250,6 @@ def _set_inline_partial(name, object, options)
248250
_set_value name, value
249251
end
250252

251-
def _render_explicit_partial(name_or_options, locals = {})
252-
case name_or_options
253-
when ::Hash
254-
# partial! partial: 'name', foo: 'bar'
255-
options = name_or_options
256-
else
257-
# partial! 'name', locals: {foo: 'bar'}
258-
if locals.one? && (locals.keys.first == :locals)
259-
locals[:partial] = name_or_options
260-
options = locals
261-
else
262-
options = { partial: name_or_options, locals: locals }
263-
end
264-
# partial! 'name', foo: 'bar'
265-
as = locals.delete(:as)
266-
options[:as] = as if as.present?
267-
options[:collection] = locals[:collection] if locals.key?(:collection)
268-
end
269-
270-
_render_partial_with_options options
271-
end
272-
273253
def _render_active_model_partial(object)
274254
@context.render object, json: self
275255
end

0 commit comments

Comments
 (0)