Method: Devise::Mapping.find_scope!
- Defined in:
- lib/devise/mapping.rb
.find_scope!(obj) ⇒ Object
Receives an object and finds a scope for it. If a scope cannot be found, raises an error. If a symbol is given, it’s considered to be the scope.
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/devise/mapping.rb', line 35 def self.find_scope!(obj) obj = obj.devise_scope if obj.respond_to?(:devise_scope) case obj when String, Symbol return obj.to_sym when Class Devise.mappings.each_value { |m| return m.name if obj <= m.to } else Devise.mappings.each_value { |m| return m.name if obj.is_a?(m.to) } end raise "Could not find a valid mapping for #{obj.inspect}" end |