Class: Common::Client::Session

Inherits:
RedisStore show all
Defined in:
lib/common/client/session.rb

Overview

A generic session model - see how RX implements it

Constant Summary collapse

EXPIRATION_THRESHOLD_SECONDS =
20

Constants inherited from RedisStore

RedisStore::REQ_CLASS_INSTANCE_VARS

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from RedisStore

create, delete, #destroy, #destroyed?, exists?, #expire, find, #initialize, #initialize_dup, keys, #persisted?, pop, redis_key, redis_store, redis_ttl, #save, #save!, #ttl, #update, #update!

Constructor Details

This class inherits a constructor from Common::RedisStore

Class Method Details

.find_or_build(attributes) ⇒ Object



17
18
19
# File 'lib/common/client/session.rb', line 17

def self.find_or_build(attributes)
  find(attributes[redis_namespace_key]) || new(attributes)
end

Instance Method Details

#expired?Boolean

Returns:

  • (Boolean)


21
22
23
24
25
# File 'lib/common/client/session.rb', line 21

def expired?
  return true if expires_at.nil?

  expires_at.to_i <= Time.now.utc.to_i + EXPIRATION_THRESHOLD_SECONDS
end

#original_jsonObject



27
28
29
# File 'lib/common/client/session.rb', line 27

def original_json
  nil
end