Sha256: 8d90afed88295dbe6c0643dac6fbd0818334fe091f5ba4868b7ec0f35da62823

Contents?: true

Size: 1.03 KB

Versions: 7

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

require "pakyow/support/extension"
require "pakyow/support/inflector"

module Pakyow
  class Application
    module Behavior
      module Sessions
        extend Support::Extension

        apply_extension do
          attr_reader :session_object, :session_options

          after "configure" do
            if config.session.enabled
              require "pakyow/application/connection/session/#{config.session.object}"

              @session_object = Pakyow::Application::Connection::Session.const_get(
                Support.inflector.classify(config.session.object)
              )

              @session_options = if config.session.respond_to?(config.session.object)
                config.session.public_send(config.session.object)
              else
                {}
              end
            end
          rescue LoadError => error
            # TODO: Improve this with a specific "session object missing" error.
            #
            raise error
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pakyow-core-1.0.6 lib/pakyow/application/behavior/sessions.rb
pakyow-core-1.0.5 lib/pakyow/application/behavior/sessions.rb
pakyow-core-1.0.4 lib/pakyow/application/behavior/sessions.rb
pakyow-core-1.0.3 lib/pakyow/application/behavior/sessions.rb
pakyow-core-1.0.2 lib/pakyow/application/behavior/sessions.rb
pakyow-core-1.0.1 lib/pakyow/application/behavior/sessions.rb
pakyow-core-1.0.0 lib/pakyow/application/behavior/sessions.rb