Created
February 6, 2010 07:41
-
-
Save nz/296603 to your computer and use it in GitHub Desktop.
This file contains 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 characters
# the basics of class reloading in ruby | |
# it's all based around unloading with Module#remove_const | |
# then reloading with Kernel#load | |
# the rest is just housekeeping | |
require 'foo' | |
Foo.exclaim! | |
Object.instance_eval { remove_const :Foo } | |
load 'foo.rb' | |
Foo.still_there? |
This file contains 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 characters
module Foo | |
def self.exclaim! | |
puts "hello, world!" | |
end | |
def self.still_there? | |
puts "why, yes, I am!" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment