From e17fe52e0e0ef0842b6c409e1110a862c4e005bc Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 29 Jan 2019 15:17:52 -0800 Subject: Tighten up the AV::Base constructor The AV::Base constructor was too complicated, and this commit tightens up the parameters it will take. At runtime, AV::Base is most commonly constructed here: https://github.com/rails/rails/blob/94d54fa4ab641a0ddeb173409cb41cc5becc02a9/actionview/lib/action_view/rendering.rb#L72-L74 This provides an AV::Renderer instance, a hash of assignments, and a controller instance. Since this is the common case for construction, we should remove logic from the constructor that handles other cases. This commit introduces special constructors for those other cases. Interestingly, most code paths that construct AV::Base "strangely" are tests. --- actionview/lib/action_view/template/handlers/erb/erubi.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionview/lib/action_view/template/handlers/erb/erubi.rb') diff --git a/actionview/lib/action_view/template/handlers/erb/erubi.rb b/actionview/lib/action_view/template/handlers/erb/erubi.rb index e155bae89d..15ca202024 100644 --- a/actionview/lib/action_view/template/handlers/erb/erubi.rb +++ b/actionview/lib/action_view/template/handlers/erb/erubi.rb @@ -26,7 +26,7 @@ module ActionView view = Class.new(ActionView::Base) { include action_view_erb_handler_context._routes.url_helpers class_eval("define_method(:_template) { |local_assigns, output_buffer| #{src} }", @filename || "(erubi)", 0) - }.new(action_view_erb_handler_context) + }.with_context(action_view_erb_handler_context) view.run(:_template, {}, ActionView::OutputBuffer.new) end -- cgit v1.2.3