Skip to content

Instantly share code, notes, and snippets.

@aereal
Created Oct 26, 2009
Embed
What would you like to do?
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