1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00
heartcombo--devise/lib/devise/strategies/base.rb

25 lines
695 B
Ruby
Raw Normal View History

2009-10-18 09:15:23 -04:00
module Devise
module Strategies
# Base strategy for Devise. Responsible for verifying correct scope and mapping.
2009-11-14 21:13:43 -05:00
module Base
2009-10-18 09:15:23 -04:00
# 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
2009-11-14 21:13:43 -05:00
mapping.for.include?(klass_type)
2009-10-18 09:15:23 -04:00
end
# Checks if a valid scope was given for devise and find mapping based on
# this scope.
def mapping
Devise.mappings[scope]
2009-11-14 21:13:43 -05:00
end
# Store this class type.
def klass_type
@klass_type ||= self.class.name.split("::").last.underscore.to_sym
2009-10-18 09:15:23 -04:00
end
end
end
end