Sha256: 57632db6dff860c53d495def1424bd0cf1d41ab6be6abc04b48084a5b4b121e1

Contents?: true

Size: 723 Bytes

Versions: 3

Compression:

Stored size: 723 Bytes

Contents

module Devise
  module Strategies
    # Base strategy for Devise. Responsible for verifying correct scope and mapping.
    class Base < ::Warden::Strategies::Base
      # Validate strategy. By default will raise an error if no scope or an
      # invalid mapping is found.
      def valid?
        raise "Could not find mapping for #{scope}" unless mapping
        mapping.for.include?(klass_type)
      end

      # Checks if a valid scope was given for devise and find mapping based on
      # this scope.
      def mapping
        Devise.mappings[scope]
      end

      # Store this class type.
      def klass_type
        @klass_type ||= self.class.name.split("::").last.underscore.to_sym
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
devise-0.9.2 lib/devise/strategies/base.rb
devise-0.9.1 lib/devise/strategies/base.rb
devise-0.9.0 lib/devise/strategies/base.rb