Class: AocCli::Components::ErrorsComponent

Inherits:
Kangaru::Component
  • Object
show all
Defined in:
lib/aoc_cli/components/errors_component.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*messages) ⇒ ErrorsComponent

Returns a new instance of ErrorsComponent.



6
7
8
# File 'lib/aoc_cli/components/errors_component.rb', line 6

def initialize(*messages)
  @messages = messages
end

Instance Attribute Details

#messagesObject (readonly)

Returns the value of attribute messages.



4
5
6
# File 'lib/aoc_cli/components/errors_component.rb', line 4

def messages
  @messages
end

Class Method Details

.from_model(model) ⇒ Object



17
18
19
20
21
# File 'lib/aoc_cli/components/errors_component.rb', line 17

def self.from_model(model)
  errors = model.errors.map(&:full_message)

  new(*errors)
end

Instance Method Details

#renderObject

TODO: remove once Kangaru has native conditional rendering



11
12
13
14
15
# File 'lib/aoc_cli/components/errors_component.rb', line 11

def render
  return unless render?

  super
end