#render_template_to_object and #render_partial_to_object are private

Apparently it had not been clear what visibility they should assume
when they were initially created at https://github.com/rails/rails/pull/35265,
then a big refactoring took place at https://github.com/rails/rails/pull/38594
after which they remain intact.

So I think they can now become properly private as they are nodoc and
not refered to but from within the same class.
This commit is contained in:
Junichi Sato 2024-01-04 10:31:18 +09:00
parent bc21ccf64b
commit 994aeacddf
No known key found for this signature in database
GPG Key ID: 6CEF8C0F22CB941D

@ -59,46 +59,46 @@ def cache_hits # :nodoc:
@cache_hits ||= {}
end
def render_template_to_object(context, options) # :nodoc:
TemplateRenderer.new(@lookup_context).render(context, options)
end
private
def render_template_to_object(context, options)
TemplateRenderer.new(@lookup_context).render(context, options)
end
def render_partial_to_object(context, options, &block) # :nodoc:
partial = options[:partial]
if String === partial
collection = collection_from_options(options)
def render_partial_to_object(context, options, &block)
partial = options[:partial]
if String === partial
collection = collection_from_options(options)
if collection
# Collection + Partial
renderer = CollectionRenderer.new(@lookup_context, options)
renderer.render_collection_with_partial(collection, partial, context, block)
else
if options.key?(:object)
# Object + Partial
renderer = ObjectRenderer.new(@lookup_context, options)
renderer.render_object_with_partial(options[:object], partial, context, block)
if collection
# Collection + Partial
renderer = CollectionRenderer.new(@lookup_context, options)
renderer.render_collection_with_partial(collection, partial, context, block)
else
# Partial
renderer = PartialRenderer.new(@lookup_context, options)
renderer.render(partial, context, block)
if options.key?(:object)
# Object + Partial
renderer = ObjectRenderer.new(@lookup_context, options)
renderer.render_object_with_partial(options[:object], partial, context, block)
else
# Partial
renderer = PartialRenderer.new(@lookup_context, options)
renderer.render(partial, context, block)
end
end
else
collection = collection_from_object(partial) || collection_from_options(options)
if collection
# Collection + Derived Partial
renderer = CollectionRenderer.new(@lookup_context, options)
renderer.render_collection_derive_partial(collection, context, block)
else
# Object + Derived Partial
renderer = ObjectRenderer.new(@lookup_context, options)
renderer.render_object_derive_partial(partial, context, block)
end
end
else
collection = collection_from_object(partial) || collection_from_options(options)
if collection
# Collection + Derived Partial
renderer = CollectionRenderer.new(@lookup_context, options)
renderer.render_collection_derive_partial(collection, context, block)
else
# Object + Derived Partial
renderer = ObjectRenderer.new(@lookup_context, options)
renderer.render_object_derive_partial(partial, context, block)
end
end
end
private
def collection_from_options(options)
if options.key?(:collection)
collection = options[:collection]