Class: NoticeComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
lib/alveole/components/notice_component.rb

Constant Summary collapse

TYPES =
%w[notice alert].freeze

Instance Method Summary collapse

Constructor Details

#initialize(title:, messages: [], type: nil) ⇒ NoticeComponent

Returns a new instance of NoticeComponent.



3
4
5
6
7
8
9
10
# File 'lib/alveole/components/notice_component.rb', line 3

def initialize(title:, messages: [], type: nil)
  super

  @type = type if TYPES.include?(type)
  @type ||= 'alert'
  @title = title
  @messages = messages
end

Instance Method Details

#render?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/alveole/components/notice_component.rb', line 12

def render?
  @messages.any?
end