符号传递给 'raise'
Symbol is passed to 'raise'
上下文代码:
module Devise
module Strategies
class AuthxAuthenticatable < Authenticatable
def valid?
!params[scope].nil?
end
def authenticate!
resource = mapping.to.authenticate_with_credentials(params[scope])
return fail(:invalid) if resource.nil?
success!(resource) if validate(resource)
end
end
end
end
Warden::Strategies.add(:authx_authenticatable, Devise::Strategies::AuthxAuthenticatable)
遇到一些将符号传递给 raise
:
的代码
raise(:invalid)
看起来没有 raise
的任何猴子补丁来处理符号参数。好像 fail
曾经被使用过,如果我使用 fail
.
代码实际上有效
那不就是raise
的别名吗?这在任何情况下都有意义吗?
看起来正在使用的 fail
方法是 warden 方法:
http://www.rubydoc.info/github/hassox/warden/Warden%2FStrategies%2FBase:fail
上下文代码:
module Devise
module Strategies
class AuthxAuthenticatable < Authenticatable
def valid?
!params[scope].nil?
end
def authenticate!
resource = mapping.to.authenticate_with_credentials(params[scope])
return fail(:invalid) if resource.nil?
success!(resource) if validate(resource)
end
end
end
end
Warden::Strategies.add(:authx_authenticatable, Devise::Strategies::AuthxAuthenticatable)
遇到一些将符号传递给 raise
:
raise(:invalid)
看起来没有 raise
的任何猴子补丁来处理符号参数。好像 fail
曾经被使用过,如果我使用 fail
.
那不就是raise
的别名吗?这在任何情况下都有意义吗?
看起来正在使用的 fail
方法是 warden 方法:
http://www.rubydoc.info/github/hassox/warden/Warden%2FStrategies%2FBase:fail