Skip to content

Instantly share code, notes, and snippets.

@taq
Created November 3, 2012 19:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taq/4008330 to your computer and use it in GitHub Desktop.
Save taq/4008330 to your computer and use it in GitHub Desktop.
Ruby 2.0 refinements
module TimeExtensions
refine Fixnum do
def minutes; self * 60; end
end
end
class MyApp
using TimeExtensions
def initialize
p 2.minutes
end
end
p TimeExtensions.refinements # => {Fixnum=>#<Module:0xb7ef49a0>}
MyApp.new # => 120
p 2.minutes # => NoMethodError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment