Class: Railsboot::ErrorsComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/railsboot/errors_component.rb

Overview

ViewComponent: renders the errors block.

Instance Method Summary collapse

Constructor Details

#initialize(*objects, **html_attributes) ⇒ ErrorsComponent

Returns a new instance of ErrorsComponent.



4
5
6
7
# File 'app/components/railsboot/errors_component.rb', line 4

def initialize(*objects, **html_attributes)
  @objects = Array(objects)
  @html_attributes = html_attributes
end

Instance Method Details

#error_messagesObject



13
14
15
# File 'app/components/railsboot/errors_component.rb', line 13

def error_messages
  errors.map(&:full_messages).flatten
end

#errorsObject



9
10
11
# File 'app/components/railsboot/errors_component.rb', line 9

def errors
  @objects.map(&:errors).flatten
end

#render?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'app/components/railsboot/errors_component.rb', line 17

def render?
  error_messages.any?
end