Class: NitroKit::Toast::FlashMessages

Inherits:
Component
  • Object
show all
Defined in:
app/components/nitro_kit/toast.rb

Instance Attribute Summary collapse

Attributes inherited from Component

#attrs

Instance Method Summary collapse

Methods inherited from Component

#builder, from_template

Constructor Details

#initialize(flash) ⇒ FlashMessages

Returns a new instance of FlashMessages.



6
7
8
# File 'app/components/nitro_kit/toast.rb', line 6

def initialize(flash)
  @flash = flash
end

Instance Attribute Details

#flashObject (readonly)

Returns the value of attribute flash.



10
11
12
# File 'app/components/nitro_kit/toast.rb', line 10

def flash
  @flash
end

Instance Method Details

#view_templateObject



12
13
14
15
16
17
18
19
20
21
# File 'app/components/nitro_kit/toast.rb', line 12

def view_template
  flash.each do |severity, message|
    render(
      Toast::Item.new(
        description: message,
        variant: severity.to_sym == :alert ? :error : :default
      )
    )
  end
end