Skip to content

Instantly share code, notes, and snippets.

@zzak
Forked from nusco/clean_room.rb
Created September 13, 2010 16:54
Show Gist options
  • Save zzak/577613 to your computer and use it in GitHub Desktop.
Save zzak/577613 to your computer and use it in GitHub Desktop.
# =================
# 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