[英]Can I use module#prepend instead of alias_method_chain to monkey patch this concern?
我正在修正Devise Token Auth gem中的問題 。
我可以通過alias_method_chain
使用它,但想知道在這種情況下是否可以使用module#prepend
代替?
注意:我們使用的是ruby 2.2.x
現有:
DeviseTokenAuth::Concerns::User.module_eval do
def token_validation_response_with_customer_info
json = token_validation_response_without_customer_info
# add some customer stuff based on has_role? check
json
end
alias_method_chain :token_validation_response, :customer_info
end
你可以試試
DeviseTokenAuth::Concerns::User.prepend(
Module.new do
def token_validation_response
json = super
# add some customer stuff based on has_role? check
json
end
end
)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.