Sha256: 28a5790d21179687de7d7a9d95ba3e2e83d36d3ee1ddbd5f452a2311e3b52359

Contents?: true

Size: 687 Bytes

Versions: 6

Compression:

Stored size: 687 Bytes

Contents

require 'hanami/action/flash'

module Hanami
  class Action
    # Session API
    #
    # This module isn't included by default.
    #
    # @since 0.1.0
    module Session
      def self.included(base)
        base.class_eval do
          before { |req, _| req.id }
        end
      end

      private

      # Finalize the response
      #
      # @return [void]
      #
      # @since 0.3.0
      # @api private
      #
      # @see Hanami::Action#finish
      def finish(req, res, *)
        if (next_flash = res.flash.next).any?
          res.session['_flash'] = next_flash
        else
          res.session.delete('_flash')
        end

        super
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
hanami-controller-2.0.0.alpha8 lib/hanami/action/session.rb
hanami-controller-2.0.0.alpha6 lib/hanami/action/session.rb
hanami-controller-2.0.0.alpha5 lib/hanami/action/session.rb
hanami-controller-2.0.0.alpha4 lib/hanami/action/session.rb
hanami-controller-2.0.0.alpha3 lib/hanami/action/session.rb
hanami-controller-2.0.0.alpha2 lib/hanami/action/session.rb