Class: Warden::SessionSerializer

Inherits:
Object
  • Object
show all
Defined in:
lib/devise/rails/warden_compat.rb

Instance Method Summary collapse

Instance Method Details

#deserialize(keys) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/devise/rails/warden_compat.rb', line 23

def deserialize(keys)
  klass, *args = keys

  begin
    ActiveSupport::Inflector.constantize(klass).serialize_from_session(*args)
  rescue NameError => e
    if e.message =~ /uninitialized constant/
      Rails.logger.debug "[Devise] Trying to deserialize invalid class #{klass}"
      nil
    else
      raise
    end
  end
end

#serialize(record) ⇒ Object



17
18
19
20
21
# File 'lib/devise/rails/warden_compat.rb', line 17

def serialize(record)
  klass = record.class
  array = klass.serialize_into_session(record)
  array.unshift(klass.name)
end