Skip to content

Instantly share code, notes, and snippets.

@nz
Created February 6, 2010 07:41
Show Gist options
  • Save nz/296603 to your computer and use it in GitHub Desktop.
Save nz/296603 to your computer and use it in GitHub Desktop.
# 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?
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