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

Instance Method Summary collapse

Instance Method Details

#mappingObject

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



15
16
17
18
19
20
21
# File 'lib/devise/strategies/base.rb', line 15

def mapping
  @mapping ||= begin
    raise "You need to give a scope for Devise authentication" unless scope
    raise "You need to give a valid Devise mapping"            unless mapping = Devise.mappings[scope]
    mapping
  end
end

#valid?Boolean

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

Returns:

  • (Boolean)


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

def valid?
  mapping.for.include?(self.class.name.split("::").last.underscore.to_sym)
end