Module: ViewComponent::RenderMonkeyPatch
- Defined in:
- lib/view_component/render_monkey_patch.rb
Overview
:nodoc:
Instance Method Summary collapse
Instance Method Details
#render(options = {}, args = {}, &block) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/view_component/render_monkey_patch.rb', line 5 def render( = {}, args = {}, &block) if .respond_to?(:render_in) && Rails.version.to_f < 6.1 .render_in(self, &block) elsif .is_a?(Class) && < ActionView::Component::Base ActiveSupport::Deprecation.warn( "`render MyComponent, foo: :bar` has been deprecated and will be removed in v2.0.0. Use `render MyComponent.new(foo: :bar)` instead." ) .new(args).render_in(self, &block) elsif .is_a?(Hash) && .has_key?(:component) && [:component] < ActionView::Component::Base ActiveSupport::Deprecation.warn( "`render component: MyComponent, locals: { foo: :bar }` has been deprecated and will be removed in v2.0.0. Use `render MyComponent.new(foo: :bar)` instead." ) [:component].new([:locals]).render_in(self, &block) elsif .respond_to?(:to_component_class) && !.to_component_class.nil? && .to_component_class < ActionView::Component::Base ActiveSupport::Deprecation.warn( "rendering objects that respond_to `to_component_class` has been deprecated and will be removed in v2.0.0. Use `render MyComponent.new(foo: :bar)` instead." ) .to_component_class.new().render_in(self, &block) else super end end |