Sha256: 071a4aa5e773e5aecae724f43640cddfb39029b21a3609a148f8f7331dba3c80

Contents?: true

Size: 571 Bytes

Versions: 18

Compression:

Stored size: 571 Bytes

Contents

module CoalescingPanda
  class Session < ActiveRecord::Base
    attr_accessible :token, :data
    serialize :data, Hash

    def self.create_from_session(session)
      params = {}
      session.keys.each do |key|
        params[key] = session[key]
      end
      token = SecureRandom.hex(10)
      Session.create(token: token, data: params)
      token
    end

    def self.restore_from_token(token, session)
      saved_session = Session.find_by_token(token)
      saved_session.data.each_pair do |key, value|
        session[key] = value
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
coalescing_panda-1.1.21.1 app/models/coalescing_panda/session.rb
coalescing_panda-1.1.21 app/models/coalescing_panda/session.rb
coalescing_panda-1.1.20 app/models/coalescing_panda/session.rb
coalescing_panda-1.4.1 app/models/coalescing_panda/session.rb
coalescing_panda-1.4.0 app/models/coalescing_panda/session.rb
coalescing_panda-1.2.2 app/models/coalescing_panda/session.rb
coalescing_panda-1.3.0 app/models/coalescing_panda/session.rb
coalescing_panda-1.2.1 app/models/coalescing_panda/session.rb
coalescing_panda-1.2.0 app/models/coalescing_panda/session.rb
coalescing_panda-1.1.19 app/models/coalescing_panda/session.rb
coalescing_panda-2.0.0 app/models/coalescing_panda/session.rb
coalescing_panda-1.1.18 app/models/coalescing_panda/session.rb
coalescing_panda-1.1.17 app/models/coalescing_panda/session.rb
coalescing_panda-1.1.16 app/models/coalescing_panda/session.rb
coalescing_panda-1.1.15 app/models/coalescing_panda/session.rb
coalescing_panda-1.1.14 app/models/coalescing_panda/session.rb
coalescing_panda-1.1.13 app/models/coalescing_panda/session.rb
coalescing_panda-1.1.12 app/models/coalescing_panda/session.rb