Sha256: 6cc4e24c0cd25f6d58db5b807ac3c9bbb080a1f6630880eb67fe4e0aa4442d41

Contents?: true

Size: 774 Bytes

Versions: 1

Compression:

Stored size: 774 Bytes

Contents

# frozen_string_literal: true

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

      def sessions_enabled?
        true
      end

      # 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::KEY] = next_flash
        else
          res.session.delete(Flash::KEY)
        end

        super
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hanami-controller-2.0.0.beta4 lib/hanami/action/session.rb