Sha256: f2a483e456d798324a11d2434d92ac5f0d6492742fdf4eeae6eca98a78d2b955

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

module Shamu
  module Sessions

    # Exposes a persistent key/value store to track state across multiple
    # requests.
    module SessionStore

      def self.create( scorpion, *args, &block )
        return scorpion.fetch Shamu::Sessions::CookieStore, *args, &block if defined? Rack

        fail "Configure a Shamu::Sessions::SessionStore in your scorpion setup."
      end

      # Fetch the value with the given key from the store. If they key does not
      # yet exist, yields to the block and caches the result.
      #
      # @param [String] key
      # @yieldreturn The calculated value of the key.
      # @return [Object]
      def fetch( key, &block )
        fail NotImplementedError
      end

      # Save a named value in the session.
      #
      # @param [String] key
      # @param [Object] value. Must be a primitive (String, Number, Hash, Array).
      # @return [value]
      def set( key, value )
        fail NotImplementedError
      end

      # Remove the value with the given key.
      # @param [String] key
      # @return [nil]
      def delete( key )
        fail NotImplementedError
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shamu-0.0.24 lib/shamu/sessions/session_store.rb