[英]Delegate static methods with Ruby on Rails?
如何使用委托來委托靜態方法?
我正在嘗試執行以下操作
例如
class MyThing
def some_instance_method(a, b)
something.some_instance_method(a, b)
end
def some_static_method(a, b)
User.some_static_method(a, b)
end
end
# can you write it this way???
class MyThing
delegate :some_instance_method, :to => :something
delegate :some_static_method, :to => User
end
class MyThing
class << self
delegate :some_static_method, :to => :User
end
end
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.