Skip to content

Instantly share code, notes, and snippets.

@GustavoCaso
Last active April 19, 2016 10:25
Show Gist options
  • Save GustavoCaso/b0e75b7ab4797cc109ed3487e650818a to your computer and use it in GitHub Desktop.
Save GustavoCaso/b0e75b7ab4797cc109ed3487e650818a to your computer and use it in GitHub Desktop.
Testing alias_class for future project
module AliasClass
def self.included(base_class)
base_class.class_eval do
def self.alias_class(original_class, new_class)
self.const_set(new_class, original_class)
end
end
end
end
class Hello
class World
class Extra
class Long
class Nesting
def hello
"Puts it took a long time to get here"
end
end
end
end
end
end
class Test
include AliasClass
alias_class Hello::World::Extra::Long::Nesting, "Greeter"
def hello
Greeter.new.hello
end
end
puts Test.new.hello
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment