Reputation: 324
How can I use delegate to delegate a static method?
I am trying to do the following
e.g.
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
Upvotes: 3
Views: 555
Reputation: 29349
class MyThing
class << self
delegate :some_static_method, :to => :User
end
end
Upvotes: 5