大佬教程收集整理的这篇文章主要介绍了ruby-on-rails – 覆盖类和实例方法的method_missing?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
或实例案例:
@H_439_2@module InstanceVersion extend ActiveSupport::Concern def method_missing(meth,&block) if meth.to_s =~ /^(.+)_async$/ Async::handle_async self,&block else super meth,&block end end # Logic for this method MUST match that of the detection in method_missing def respond_to_missing?(method_name,include_private = falsE) Async::async?(method_Name) || super end end……我似乎无法在同一个班级支持这两种情况.有没有更好的方法来覆盖method_missing,以便支持这两种情况?我在Rails 3.2上….
您需要做的是停止使用ActiveSupport :: Concern并编写包含的钩子以满足您的特定需求:
@H_439_2@module AsyncModule def method_missing(meth,&block) if meth.to_s =~ /^(.+)_async$/ Async::handle_async self,&block else super meth,&block end end # Logic for this method MUST match that of the detection in method_missing def respond_to_missing?(method_name,include_private = falsE) Async::async?(method_Name) || super end private def self.included(basE) base.extend self end end以上是大佬教程为你收集整理的ruby-on-rails – 覆盖类和实例方法的method_missing?全部内容,希望文章能够帮你解决ruby-on-rails – 覆盖类和实例方法的method_missing?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。