Skip to content

Instantly share code, notes, and snippets.

@revathskumar
Last active December 17, 2015 08:18
Show Gist options
  • Save revathskumar/5578817 to your computer and use it in GitHub Desktop.
Save revathskumar/5578817 to your computer and use it in GitHub Desktop.
testObj = SomeModule::Test.new
testObj.create_class "airtel" # Creates a new class Airtel
Airtel.new.hello_class # prints Hello from new class
SomeModule.const_set(name.classify,
Class.new(SomeModule::Test) do
def hello_class
p self.class.ancestors
p "Hello from new class"
end
end
)
SomeModule.const_set(name.classify,
Class.new do
def hello_class
p "Hello from new class"
end
end
)
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