Created
March 4, 2014 16:51
-
-
Save nusco/9350331 to your computer and use it in GitHub Desktop.
Revisions
-
nusco revised this gist
Mar 4, 2014 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -13,7 +13,6 @@ def reverse end "abc".reverse # => "cba" using MyRefinement "abc".reverse # => "my reverse" -
nusco created this gist
Mar 4, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ # ================= # Spell: Refinement # ================= # Patch a class until the end of the file, or (from Ruby 2.1) until the end of the including module. module MyRefinement refine String do def reverse "my reverse" end end end "abc".reverse # => "cba" using MyRefinement "abc".reverse # => "my reverse" # For more information: http://www.pragprog.com/titles/ppmetr/metaprogramming-ruby