Module: ActionView::Base::RenderMonkeyPatch

Included in:
ActionView::Base
Defined in:
lib/action_view/component/base.rb

Instance Method Summary collapse

Instance Method Details

#render(options = {}, args = {}, &block) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/action_view/component/base.rb', line 9

def render(options = {}, args = {}, &block)
  if options.respond_to?(:render_in)
    ActiveSupport::Deprecation.warn(
      "passing component instances to `render` has been deprecated and will be removed in v2.0.0. Use `render MyComponent, foo: :bar` instead."
    )

    options.render_in(self, &block)
  elsif options.is_a?(Class) && options < ActionView::Component::Base
    options.new(args).render_in(self, &block)
  elsif options.is_a?(Hash) && options.has_key?(:component)
    options[:component].new(options[:locals]).render_in(self, &block)
  else
    super
  end
end