Created
November 3, 2012 19:16
-
-
Save taq/4008330 to your computer and use it in GitHub Desktop.
Ruby 2.0 refinements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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