Skip to content

Instantly share code, notes, and snippets.

@nusco
Created August 18, 2010 15:02
Show Gist options
  • Save nusco/535023 to your computer and use it in GitHub Desktop.
Save nusco/535023 to your computer and use it in GitHub Desktop.
Spell: Clean Room
# =================
# Spell: Clean Room
# =================
# Use an object as an environment in which to evaluate a block.
class CleanRoom
def a_useful_method(x); x * 2; end
end
CleanRoom.new.instance_eval { a_useful_method(3) } # => 6
# 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