Skip to content

Instantly share code, notes, and snippets.

@aereal
Created October 26, 2009 16:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aereal/218780 to your computer and use it in GitHub Desktop.
Save aereal/218780 to your computer and use it in GitHub Desktop.
Python's 'import' like it
def import(feature, as={})
ret = require feature
self.class.instance_eval do
as.each do |(orig, dest)|
c = const_get(orig)
remove_const(orig) if const_defined?(orig)
const_set(dest, c)
end
end unless as.empty?
ret
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment