user3179047
user3179047

Reputation: 324

Delegate static methods with Ruby on Rails?

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

Answers (1)

usha
usha

Reputation: 29349

class MyThing
  class << self
    delegate :some_static_method, :to => :User
  end
end

Upvotes: 5

Related Questions