Module: Shamu::Sessions::SessionStore

Included in:
CookieStore
Defined in:
lib/shamu/sessions/session_store.rb

Overview

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.create(scorpion, *args, **dependencies, &block) ⇒ Object



8
9
10
11
12
# File 'lib/shamu/sessions/session_store.rb', line 8

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

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

Instance Method Details

#delete(key) ⇒ nil

Remove the value with the given key.

Parameters:

  • key (String)

Returns:

  • (nil)


36
37
38
# File 'lib/shamu/sessions/session_store.rb', line 36

def delete( key )
  fail NotImplementedError
end

#fetch(key, &block) ⇒ Object

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.

Parameters:

  • key (String)

Yield Returns:

  • The calculated value of the key.

Returns:

  • (Object)


20
21
22
# File 'lib/shamu/sessions/session_store.rb', line 20

def fetch( key, &block )
  fail NotImplementedError
end

#set(key, value) ⇒ value

Save a named value in the session.

Parameters:

  • key (String)
  • value. (Object)

    Must be a primitive (String, Number, Hash, Array).

Returns:

  • (value)


29
30
31
# File 'lib/shamu/sessions/session_store.rb', line 29

def set( key, value )
  fail NotImplementedError
end