Class: ViewComponent::Collection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/view_component/collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#__vc_original_view_contextObject

Returns the value of attribute __vc_original_view_context.



12
13
14
# File 'lib/view_component/collection.rb', line 12

def __vc_original_view_context
  @__vc_original_view_context
end

#componentObject (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



25
26
27
# File 'lib/view_component/collection.rb', line 25

def each(&block)
  components.each(&block)
end

#render_in(view_context, &block) ⇒ Object



18
19
20
21
22
23
# File 'lib/view_component/collection.rb', line 18

def render_in(view_context, &block)
  components.map do |component|
    component.set_original_view_context(__vc_original_view_context)
    component.render_in(view_context, &block)
  end.join(rendered_spacer(view_context)).html_safe
end

#set_original_view_context(view_context) ⇒ Object



14
15
16
# File 'lib/view_component/collection.rb', line 14

def set_original_view_context(view_context)
  self.__vc_original_view_context = view_context
end