Class: Practical::Views::Form::ErrorListItemComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/practical/views/form/error_list_item_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error:) ⇒ ErrorListItemComponent

Returns a new instance of ErrorListItemComponent.



6
7
8
# File 'app/components/practical/views/form/error_list_item_component.rb', line 6

def initialize(error:)
  @error = error
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



4
5
6
# File 'app/components/practical/views/form/error_list_item_component.rb', line 4

def error
  @error
end

Instance Method Details

#before_renderObject



10
11
12
# File 'app/components/practical/views/form/error_list_item_component.rb', line 10

def before_render
  error.options[:has_been_rendered] = true
end

#callObject



14
15
16
17
18
19
# File 'app/components/practical/views/form/error_list_item_component.rb', line 14

def call
  tag.li(class: 'wa-flank', data: {"error-type": error.type}) {
    render(icon_set.error_list_icon) +
    tag.span(error.message)
  }
end