RubyFlow The Ruby and Rails community linklog

Refinements in Ruby

Ruby 1.9 will soon get a better way to monkey patch classes. Read all about them in Refinements in Ruby!

Comments

This is exciting stuff. Finally! This is very similar to the namespace approach I and other proposed long ago. The key difference being #using to active the patches. Based on those old ideas, I wonder if the #refine method is actually necessary. Would this not do as well?

  module TimeExtensions
    class Fixnum
      def minutes; self * 60; end
    end
  end

  class MyApp
    using TimeExtensions

    def initialize
      p 2.minutes
    end
  end

I like it!

This is VERY promising

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in