Sha256: f7bcff1cd149a2bb200a95c4f157df3af4b074e6a78b3555aa54aa28ec371469

Contents?: true

Size: 537 Bytes

Versions: 116

Compression:

Stored size: 537 Bytes

Contents

module CoalescingPanda
  class Session < ActiveRecord::Base
    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

116 entries across 116 versions & 1 rubygems

Version Path
coalescing_panda-5.3.0 app/models/coalescing_panda/session.rb
coalescing_panda-5.2.2 app/models/coalescing_panda/session.rb
coalescing_panda-5.2.2.beta1 app/models/coalescing_panda/session.rb
coalescing_panda-5.2.1 app/models/coalescing_panda/session.rb
coalescing_panda-5.2.0 app/models/coalescing_panda/session.rb
coalescing_panda-5.2.0.beta2 app/models/coalescing_panda/session.rb
coalescing_panda-5.2.0.beta1 app/models/coalescing_panda/session.rb
coalescing_panda-5.1.13 app/models/coalescing_panda/session.rb
coalescing_panda-5.1.12 app/models/coalescing_panda/session.rb
coalescing_panda-5.1.11 app/models/coalescing_panda/session.rb
coalescing_panda-5.1.10 app/models/coalescing_panda/session.rb
coalescing_panda-5.1.9 app/models/coalescing_panda/session.rb
coalescing_panda-5.1.8 app/models/coalescing_panda/session.rb
coalescing_panda-5.1.7 app/models/coalescing_panda/session.rb
coalescing_panda-5.1.6 app/models/coalescing_panda/session.rb
coalescing_panda-5.1.5 app/models/coalescing_panda/session.rb
coalescing_panda-5.1.4 app/models/coalescing_panda/session.rb
coalescing_panda-5.1.3.beta.2 app/models/coalescing_panda/session.rb
coalescing_panda-5.1.3.beta.1 app/models/coalescing_panda/session.rb
coalescing_panda-5.1.3 app/models/coalescing_panda/session.rb