Skip to content

Instantly share code, notes, and snippets.

@boggle
Created April 26, 2012 16:01
Show Gist options
  • Save boggle/2500585 to your computer and use it in GitHub Desktop.
Save boggle/2500585 to your computer and use it in GitHub Desktop.
Nice way to add reloading support to a ruby gem's top-level module
module Foo
def self.files
f = []
f << 'foo/a'
f << 'foo/b'
f
end
def self.load_relative(f)
path = "#{File.join(File.dirname(caller[0]), f)}.rb"
load path
end
def self.reload!
files.each { |f| load_relative f }
end
end
# normal loading during require
Foo.files.each { |f| require_relative f }
# reloading in irb
Foo.reload!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment