Skip to content

Instantly share code, notes, and snippets.

@justinko
Created December 22, 2011 05:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save justinko/1509034 to your computer and use it in GitHub Desktop.
Save justinko/1509034 to your computer and use it in GitHub Desktop.
Avdi Grimm's creation, pulled from Objects on Rails
def stub_module(full_name)
full_name.to_s.split(/::/).inject(Object) do |context, name|
begin
context.const_get(name)
rescue NameError
context.const_set(name, Module.new)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment