Last active
April 19, 2016 10:25
-
-
Save GustavoCaso/b0e75b7ab4797cc109ed3487e650818a to your computer and use it in GitHub Desktop.
Testing alias_class for future project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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