Class: Booth::Userland::ExtractFlashMessages
- Inherits:
-
Object
- Object
- Booth::Userland::ExtractFlashMessages
- Includes:
- Logging, Calls
- Defined in:
- lib/booth/userland/extract_flash_messages.rb
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/booth/userland/extract_flash_messages.rb', line 17 def call check_arguments! return unless from.respond_to?(:public_message) return if from..blank? if from.success? log { "Saving flash notice: #{from.public_message}" } to[:notice] = from. else log { "Saving flash alert: #{from.public_message}" } to[:alert] = from. end nil end |
#check_arguments! ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/booth/userland/extract_flash_messages.rb', line 33 def check_arguments! raise(ArgumentError, 'You can only extract flash messages from something that is not nil') if from.nil? return if to.respond_to?(:notice=) raise ArgumentError, "Please pass in `to: flash` for public flash messages not #{to.inspect}" end |