class Devise::Mapping

def self.find_scope!(duck)

raises an error. If a symbol is given, it's considered to be the scope.
Receives an object and find a scope for it. If a scope cannot be found,
def self.find_scope!(duck)
  case duck
  when String, Symbol
    return duck
  when Class
    Devise.mappings.each_value { |m| return m.name if duck <= m.to }
  else
    Devise.mappings.each_value { |m| return m.name if duck.is_a?(m.to) }
  end
  raise "Could not find a valid mapping for #{duck.inspect}"
end