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.

Revisions

  1. @nusco nusco created this gist Mar 4, 2014.
    18 changes: 18 additions & 0 deletions refinement_wrapper.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    # =========================
    # 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