Sha256: 3310242b33c19b353defa5f0646f0547180ab74e0181ff5068923e7b81a8b252

Contents?: true

Size: 962 Bytes

Versions: 4

Compression:

Stored size: 962 Bytes

Contents

# frozen_string_literal: true

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

module Pakyow
  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/app/connection/session/#{config.session.object}"

            @session_object = Pakyow::App::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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pakyow-core-1.0.0.rc5 lib/pakyow/behavior/sessions.rb
pakyow-core-1.0.0.rc4 lib/pakyow/behavior/sessions.rb
pakyow-core-1.0.0.rc3 lib/pakyow/behavior/sessions.rb
pakyow-core-1.0.0.rc2 lib/pakyow/behavior/sessions.rb