Class: Hanami::Config::Actions::Sessions
- Inherits:
-
Object
- Object
- Hanami::Config::Actions::Sessions
- Defined in:
- lib/hanami/config/actions/sessions.rb
Overview
Config for HTTP session middleware in Hanami actions.
Instance Attribute Summary collapse
-
#options ⇒ Array
readonly
Returns the configured session storage options.
-
#storage ⇒ Symbol
readonly
Returns the configured session storage.
Instance Method Summary collapse
-
#enabled? ⇒ Boolean
Returns true if sessions have been enabled.
-
#initialize(storage = nil, *options) ⇒ Sessions
constructor
private
Returns a new ‘Sessions`.
-
#middleware ⇒ Array<(Symbol, Array)>
Returns an array of the session storage middleware name and its options, or an empty array if sessions have not been enabled.
Constructor Details
#initialize(storage = nil, *options) ⇒ 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.
Returns a new ‘Sessions`.
You should not need to initialize this class directly. Instead use Hanami::Config::Actions#sessions=.
40 41 42 43 |
# File 'lib/hanami/config/actions/sessions.rb', line 40 def initialize(storage = nil, *) @storage = storage @options = end |
Instance Attribute Details
#options ⇒ Array (readonly)
Returns the configured session storage options
28 29 30 |
# File 'lib/hanami/config/actions/sessions.rb', line 28 def @options end |
#storage ⇒ Symbol (readonly)
Returns the configured session storage
20 21 22 |
# File 'lib/hanami/config/actions/sessions.rb', line 20 def storage @storage end |
Instance Method Details
#enabled? ⇒ Boolean
Returns true if sessions have been enabled.
51 52 53 |
# File 'lib/hanami/config/actions/sessions.rb', line 51 def enabled? !storage.nil? end |
#middleware ⇒ Array<(Symbol, Array)>
Returns an array of the session storage middleware name and its options, or an empty array if sessions have not been enabled.
62 63 64 65 66 |
# File 'lib/hanami/config/actions/sessions.rb', line 62 def middleware return [] unless enabled? [storage_middleware, ].flatten(1) end |