Skip to content

Instantly share code, notes, and snippets.

@loz
Created October 25, 2011 06:57
Show Gist options
  • Save loz/1311644 to your computer and use it in GitHub Desktop.
Save loz/1311644 to your computer and use it in GitHub Desktop.
File.open('hello.rb', 'wb') {|f| f.write 'class Hello; end' }
x = Module.new
file = File.open('hello.rb') {|f| f.read }
x.module_eval(file)
x::Hello
#Patch Module:
class Module
public
def load_from_file(file)
self.module_eval(File.open(file) {|f| f.read})
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment