Class: Nquery::FlashCardsComponent
- Defined in:
- app/components/nquery/flash_cards_component.rb
Instance Method Summary collapse
- #any? ⇒ Boolean
- #cards ⇒ Object
-
#initialize(flash:) ⇒ FlashCardsComponent
constructor
A new instance of FlashCardsComponent.
Methods inherited from Component
Constructor Details
#initialize(flash:) ⇒ FlashCardsComponent
Returns a new instance of FlashCardsComponent.
5 6 7 |
# File 'app/components/nquery/flash_cards_component.rb', line 5 def initialize(flash:) @flash = flash end |
Instance Method Details
#any? ⇒ Boolean
16 17 18 |
# File 'app/components/nquery/flash_cards_component.rb', line 16 def any? cards.any? end |
#cards ⇒ Object
9 10 11 12 13 14 |
# File 'app/components/nquery/flash_cards_component.rb', line 9 def cards [].tap do |list| list << FlashCardComponent.new(message: @flash[:notice], type: :notice) if @flash[:notice].present? list << FlashCardComponent.new(message: @flash[:alert], type: :alert) if @flash[:alert].present? end end |