Understanding [ClassOne, ClassTwo].each(&:my_method) [duplicate]

This relies upon a Ruby 1.9 extension that can be done in 1.8 by including the following:

class Symbol
    def to_proc
      proc { |obj, *args| obj.send(self, *args) }
    end
end

I believe Rails defines this in ActiveSupport.

Leave a Comment