Class: Hanami::Config::Sessions Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/config/sessions.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Sessions configuration

Since:

  • 0.2.0

Constant Summary collapse

RACK_NAMESPACE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Ruby namespace for Rack session adapters

Since:

  • 0.2.0

'Rack::Session::%s'.freeze
BLACKLISTED_DOMAINS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Localhost string for detecting localhost host configuration

Since:

  • 0.2.0

%w(localhost).freeze

Instance Method Summary collapse

Constructor Details

#initialize(adapter = nil, options = {}, configuration = nil) ⇒ Sessions

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

HTTP sessions configuration

Parameters:

  • adapter (Symbol, String, Class) (defaults to: nil)

    the session adapter

  • options (Hash) (defaults to: {})

    the optional session options

  • configuration (Hanami::Configuration) (defaults to: nil)

    the application configuration

See Also:

Since:

  • 0.2.0



37
38
39
40
41
# File 'lib/hanami/config/sessions.rb', line 37

def initialize(adapter = nil, options = {}, configuration = nil)
  @adapter       = adapter
  @options       = options
  @configuration = configuration
end

Instance Method Details

#enabled?FalseClass, TrueClass

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Check if the sessions are enabled

Returns:

  • (FalseClass, TrueClass)

    the result of the check

Since:

  • 0.2.0



49
50
51
# File 'lib/hanami/config/sessions.rb', line 49

def enabled?
  !!@adapter
end

#middlewareArray

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the Rack middleware and the options

Returns:

  • (Array)

    Rack middleware and options

Since:

  • 0.2.0



59
60
61
62
63
64
65
66
67
68
# File 'lib/hanami/config/sessions.rb', line 59

def middleware
  middleware = case @adapter
               when Symbol
                 RACK_NAMESPACE % Utils::String.classify(@adapter)
               else
                 @adapter
               end

  [middleware, options]
end