Module: FlushingFlash::ActionControllerMethods::InstanceMethods
- Defined in:
- lib/flushing-flash/action_controller_methods.rb
Instance Method Summary collapse
- #pull_flash(target = :default) ⇒ Object
- #push_flash(message_type, *args) ⇒ Object
- #to_flushing_flash_message(message_type, flash_content) ⇒ Object
Instance Method Details
#pull_flash(target = :default) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/flushing-flash/action_controller_methods.rb', line 32 def pull_flash(target=:default) @pulled_flashes ||= {} return @pulled_flashes[target] if @pulled_flashes[target] pulled_flashes = flash[target] || [] flash.delete(target) if pulled_flashes.is_a?(Array) @pulled_flashes[target] = pulled_flashes else @pulled_flashes[target] = [(target, pulled_flashes)] end @pulled_flashes[target] end |
#push_flash(message_type, *args) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/flushing-flash/action_controller_methods.rb', line 13 def push_flash(, *args) opts = args. = opts.delete(:i18n_options) target = opts.delete(:target) || :default flash_content = case args[0].class.name when String.name args[0] when Symbol.name I18n.t("flashes.#{args[0]}.#{}", ) else I18n.t("flashes.#{self.class.name.gsub(/Controller$/, "").underscore.gsub(/\//, ".")}.#{action_name.underscore}.#{}", ) end flash[target] ||= [] flash[target] << (, flash_content) end |
#to_flushing_flash_message(message_type, flash_content) ⇒ Object
48 49 50 |
# File 'lib/flushing-flash/action_controller_methods.rb', line 48 def (, flash_content) { message_type: , content: flash_content } end |