Class: Lotus::Config::Sessions Private

Inherits:
Object
  • Object
show all
Defined in:
lib/lotus/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 (Lotus::Configuration) (defaults to: nil)

    the application configuration

See Also:

Since:

  • 0.2.0



34
35
36
37
38
# File 'lib/lotus/config/sessions.rb', line 34

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



46
47
48
# File 'lib/lotus/config/sessions.rb', line 46

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



56
57
58
59
60
61
62
63
64
65
# File 'lib/lotus/config/sessions.rb', line 56

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

  [middleware, options]
end