mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
30 lines
703 B
Ruby
30 lines
703 B
Ruby
require 'devise/strategies/base'
|
|
|
|
module Devise
|
|
module Serializers
|
|
module Base
|
|
include Devise::Strategies::Base
|
|
attr_reader :scope
|
|
|
|
def serialize(record)
|
|
record.class.send(:"serialize_into_#{serialization_type}", record)
|
|
end
|
|
|
|
def deserialize(keys)
|
|
mapping.to.send(:"serialize_from_#{serialization_type}", keys)
|
|
end
|
|
|
|
def fetch(scope)
|
|
@scope = scope
|
|
super
|
|
end
|
|
|
|
def serialization_type
|
|
@serialization_type ||= begin
|
|
warden = self.class.ancestors.find{ |k| k < Warden::Serializers::Base && k != self.class }
|
|
warden.name.split("::").last.underscore
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|