Sha256: 6d1fa9473e6be6bc0800dcf4c1aec297675018cbeccc47cedb927d99a577bf49

Contents?: true

Size: 625 Bytes

Versions: 7

Compression:

Stored size: 625 Bytes

Contents

module Surikat

  require 'surikat/session_manager'

  class Session

    def initialize(session_key)
      @manager = Surikat::SessionManager.new
      @session_key = session_key
      @this_session = @manager[session_key] || {}

      if @this_session.blank? && !@session_key.blank?
        @manager.merge! @session_key, {created_at: Time.now}
      end
    end

    def [](key)
      @this_session[key]
    end

    def []=(key, value)
      @manager.merge! @session_key, {key => value}
    end

    def delete(key)
      @manager.delete_key! @session_key, key
    end

    def to_h
      @this_session
    end

  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
surikat-0.3.2 lib/surikat/session.rb
surikat-0.3.1 lib/surikat/session.rb
surikat-0.3.0 lib/surikat/session.rb
surikat-0.2.5 lib/surikat/session.rb
surikat-0.2.4 lib/surikat/session.rb
surikat-0.2.3 lib/surikat/session.rb
surikat-0.2.2 lib/surikat/session.rb