Class: FoxTail::WrapperComponent

Inherits:
BaseComponent show all
Defined in:
app/components/fox_tail/wrapper_component.rb

Instance Attribute Summary collapse

Attributes inherited from BaseComponent

#html_attributes

Instance Method Summary collapse

Methods inherited from BaseComponent

classname_merger, stimulus_merger, use_stimulus?, #with_html_attributes, #with_html_class

Methods inherited from Base

fox_tail_config

Constructor Details

#initialize(html_attributes = {}, &block) ⇒ WrapperComponent

Returns a new instance of WrapperComponent.



6
7
8
9
# File 'app/components/fox_tail/wrapper_component.rb', line 6

def initialize(html_attributes = {}, &block)
  super(html_attributes)
  @block = block
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



4
5
6
# File 'app/components/fox_tail/wrapper_component.rb', line 4

def block
  @block
end

Instance Method Details

#before_renderObject



15
16
17
18
19
# File 'app/components/fox_tail/wrapper_component.rb', line 15

def before_render
  super

  html_attributes[:class] = html_class
end

#block?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'app/components/fox_tail/wrapper_component.rb', line 11

def block?
  !!@block
end

#callObject



25
26
27
# File 'app/components/fox_tail/wrapper_component.rb', line 25

def call
  block ? capture(self, &block) : content
end

#render?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'app/components/fox_tail/wrapper_component.rb', line 21

def render?
  block? || content?
end