Class: Devise::Strategies::Base

Inherits:
Warden::Strategies::Base
  • Object
show all
Defined in:
lib/devise/strategies/base.rb

Overview

Base strategy for Devise. Responsible for verifying correct scope and mapping.

Direct Known Subclasses

Authenticatable, Rememberable

Instance Method Summary collapse

Instance Method Details

#klass_typeObject

Store this class type.



19
20
21
# File 'lib/devise/strategies/base.rb', line 19

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

#mappingObject

Checks if a valid scope was given for devise and find mapping based on this scope.



14
15
16
# File 'lib/devise/strategies/base.rb', line 14

def mapping
  Devise.mappings[scope]
end

#valid?Boolean

Validate strategy. By default will raise an error if no scope or an invalid mapping is found.

Returns:



7
8
9
10
# File 'lib/devise/strategies/base.rb', line 7

def valid?
  raise "Could not find mapping for #{scope}" unless mapping
  mapping.for.include?(klass_type)
end