module Coco class Toast < Coco::Component include Concerns::WrapsComponent include Concerns::ActsAsNotification accepts_option :dismissable, from: [true, false], default: true accepts_option :dismiss, from: [true, false], default: false wraps_component :alert do |args| Coco::Alert.new(**args, dismissable: get_option_value(:dismissable)) end %i[title action secondary_action link].each do |slot_name| renders_one slot_name, ->(**kwargs, &block) do alert.send(:"with_#{slot_name}", **kwargs, &block) end end end end