dimanche 10 septembre 2017

Ruby class method reference

In Ruby, we can easily reference a method and pass in a callback-like fashion in the same scope like this:

my_method = method(:method_name)

How would you reference a class method defined on another class?

So if I had:

class MyClass
  class << self
      def my_method
        // ... do stuff
      end
  end
end

How would I reference that method in a different class to use in a method(...) call?





Aucun commentaire:

Enregistrer un commentaire