Sha256: 270b23f99c1dad76b2d133e76c6656ef0ad30357e079a6f1fa58e9d082961935

Contents?: true

Size: 914 Bytes

Versions: 6

Compression:

Stored size: 914 Bytes

Contents

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 store(user, scope)
        @scope = scope
        return unless valid?
        super
      end

      def fetch(scope)
        @scope = scope
        return unless valid?
        super
      end

      def delete(scope, user=nil)
        @scope = scope
        return unless valid?
        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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
devise-0.5.6 lib/devise/serializers/base.rb
devise-0.5.5 lib/devise/serializers/base.rb
devise-0.5.4 lib/devise/serializers/base.rb
devise-0.5.3 lib/devise/serializers/base.rb
devise-0.5.2 lib/devise/serializers/base.rb
devise-0.5.1 lib/devise/serializers/base.rb