Skip to content

Instantly share code, notes, and snippets.

@GorillaTester
Forked from nusco/refinement_wrapper.rb
Last active September 15, 2015 06:20
Show Gist options
  • Select an option

  • Save GorillaTester/e50b490f17a2b09826bc to your computer and use it in GitHub Desktop.

Select an option

Save GorillaTester/e50b490f17a2b09826bc to your computer and use it in GitHub Desktop.
Spell: Refinement Wrapper
# =========================
# Spell: Refinement Wrapper
# =========================
# Call an unrefined method from its refinement.
module StringRefinement
refine String do
def reverse
"x#{super}x"
end
end
end
using StringRefinement
"abc".reverse # => "xcbax"
# For more information: http://www.pragprog.com/titles/ppmetr/metaprogramming-ruby
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment