Module: ViewComponentAttributes::WithRoot
- Extended by:
- ActiveSupport::Concern
- Includes:
- WithAttributes
- Defined in:
- lib/view_component_attributes/with_root.rb
Instance Method Summary collapse
- #root(template_root = nil, **template_attributes, &block) ⇒ Object
- #root_attributes(**template_attributes) ⇒ Object
- #root_type(template_root) ⇒ Object
Methods included from WithAttributes
Instance Method Details
#root(template_root = nil, **template_attributes, &block) ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'lib/view_component_attributes/with_root.rb', line 68 def root(template_root = nil, **template_attributes, &block) root_to_render = root_type(template_root) if root_to_render.is_a?(Class) render(root_to_render.new(**root_attributes(**template_attributes)), &block) else tag.send(root_to_render, **root_attributes(**template_attributes), &block) end end |
#root_attributes(**template_attributes) ⇒ Object
82 83 84 |
# File 'lib/view_component_attributes/with_root.rb', line 82 def root_attributes(**template_attributes) template_attributes end |
#root_type(template_root) ⇒ Object
78 79 80 |
# File 'lib/view_component_attributes/with_root.rb', line 78 def root_type(template_root) @root_type ||= attribute(:root) || template_root || default_root end |