Skip to content

Instantly share code, notes, and snippets.

@b-murphy
Created October 28, 2014 15:02
Show Gist options
  • Save b-murphy/a54a173633a404cd54e1 to your computer and use it in GitHub Desktop.
Save b-murphy/a54a173633a404cd54e1 to your computer and use it in GitHub Desktop.
# what's the expectation for the require within constant (non global state)
# like this?
require "mary.rb"
Bob = Module.new {}
# Or this?
Bob = Module.new {
require('mary.rb')
}
@bestie
Copy link

bestie commented Oct 28, 2014

I don't think Module defines a require method. I think you want

Module.new {
  module_eval(File.read("mary.rb"))
}

Which is more like load with the wrap=true flag set but more useful.

Do want to work on better_require with me.

@b-murphy
Copy link
Author

I do, I was just trying to get the context of better_require, I was having a dig around MRI files, to see the inner workings :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment