module Hanami::Action::Session

Session support for actions.

Not included by default; you should include this module manually to enable session support. For actions within an Hanami app, this module will be included automatically if sessions are configured in the app config.

@api public @since 0.1.0

Public Class Methods

included(base) click to toggle source

@api private @since 0.1.0

# File lib/hanami/action/session.rb, line 16
def self.included(base)
  base.class_eval do
    before { |req, _| req.id }
  end
end

Private Instance Methods

finish(req, res, *) click to toggle source

Finalize the response

@return [void]

@since 0.3.0 @api private

@see Hanami::Action#finish

Calls superclass method
# File lib/hanami/action/session.rb, line 36
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
session_enabled?() click to toggle source
# File lib/hanami/action/session.rb, line 24
def session_enabled?
  true
end