From 994aeacddf6d2d9ddd7b76216a56e6040aac5b77 Mon Sep 17 00:00:00 2001 From: Junichi Sato <22004610+sato11@users.noreply.github.com> Date: Thu, 4 Jan 2024 10:31:18 +0900 Subject: [PATCH] `#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. --- .../lib/action_view/renderer/renderer.rb | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/actionview/lib/action_view/renderer/renderer.rb b/actionview/lib/action_view/renderer/renderer.rb index f86bc61426..8330092931 100644 --- a/actionview/lib/action_view/renderer/renderer.rb +++ b/actionview/lib/action_view/renderer/renderer.rb @@ -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]