Class: ViewComponent::Collection
- Inherits:
-
Object
- Object
- ViewComponent::Collection
- Includes:
- Enumerable
- Defined in:
- lib/view_component/collection.rb
Instance Attribute Summary collapse
-
#component ⇒ Object
readonly
Returns the value of attribute component.
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#format ⇒ Object
Rails expects us to define ‘format` on all renderables, but we do not know the `format` of a ViewComponent until runtime.
- #render_in(view_context, &block) ⇒ Object
Instance Attribute Details
#component ⇒ Object (readonly)
Returns the value of attribute component.
8 9 10 |
# File 'lib/view_component/collection.rb', line 8 def component @component end |
Instance Method Details
#each(&block) ⇒ Object
18 19 20 |
# File 'lib/view_component/collection.rb', line 18 def each(&block) components.each(&block) end |
#format ⇒ Object
Rails expects us to define ‘format` on all renderables, but we do not know the `format` of a ViewComponent until runtime.
25 26 27 |
# File 'lib/view_component/collection.rb', line 25 def format nil end |
#render_in(view_context, &block) ⇒ Object
12 13 14 15 16 |
# File 'lib/view_component/collection.rb', line 12 def render_in(view_context, &block) components.map do |component| component.render_in(view_context, &block) end.join(rendered_spacer(view_context)).html_safe end |