Last active
December 17, 2015 08:18
-
-
Save revathskumar/5578817 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
testObj = SomeModule::Test.new | |
testObj.create_class "airtel" # Creates a new class Airtel | |
Airtel.new.hello_class # prints Hello from new class |
This file contains hidden or 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
SomeModule.const_set(name.classify, | |
Class.new(SomeModule::Test) do | |
def hello_class | |
p self.class.ancestors | |
p "Hello from new class" | |
end | |
end | |
) |
This file contains hidden or 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
SomeModule.const_set(name.classify, | |
Class.new do | |
def hello_class | |
p "Hello from new class" | |
end | |
end | |
) |
This file contains hidden or 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 SomeModule | |
class Test | |
def create_class name | |
Object.const_set(name.classify, | |
Class.new do | |
def hello_class | |
p "Hello from new class" | |
end | |
end | |
) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment