Class: Blacklight::System::FlashMessageComponent
- Inherits:
-
Component
- Object
- ViewComponent::Base
- Component
- Blacklight::System::FlashMessageComponent
show all
- Defined in:
- app/components/blacklight/system/flash_message_component.rb
Constant Summary
Constants inherited
from Component
Component::EXCLUDE_VARIABLES
Instance Method Summary
collapse
Methods inherited from Component
compiler, config, #inspect
Constructor Details
Returns a new instance of FlashMessageComponent.
10
11
12
13
|
# File 'app/components/blacklight/system/flash_message_component.rb', line 10
def initialize(message: nil, type:)
@message = message
@classes = alert_class(type)
end
|
Instance Method Details
#alert_class(type) ⇒ Object
19
20
21
22
23
24
25
26
27
|
# File 'app/components/blacklight/system/flash_message_component.rb', line 19
def alert_class(type)
case type.to_s
when 'success' then "alert-success"
when 'notice' then "alert-info"
when 'alert' then "alert-warning"
when 'error' then "alert-danger"
else "alert-#{type}"
end
end
|
#before_render ⇒ Object
15
16
17
|
# File 'app/components/blacklight/system/flash_message_component.rb', line 15
def before_render
with_message { @message } if @message
end
|