Class: Nquery::FlashCardsComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/nquery/flash_cards_component.rb

Instance Method Summary collapse

Methods inherited from Component

render_in, #render_in

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

Returns:

  • (Boolean)


16
17
18
# File 'app/components/nquery/flash_cards_component.rb', line 16

def any?
  cards.any?
end

#cardsObject



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