Created
May 20, 2011 16:26
-
-
Save marciol/983268 to your computer and use it in GitHub Desktop.
Exemplo para criação de classe dinamica via(Alexandre Angelim)
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
class Pai | |
def self.mirrored_in(klass_name, &block) | |
klass = Class.new do | |
def bar | |
puts "bar" | |
end | |
end | |
klass.class_eval &block | |
Object.const_set klass_name, klass | |
end | |
mirrored_in "Filho" do | |
def self.grita;puts "ei";end | |
puts "gritando" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment