T
trans. (T. Onoma)
Here's a wee challenge for Rubyists at large. Consider:
module M
class A
def initialize ; puts "A" ; end
end
def a
A.new
end
class B
def initialize ; puts "B" ; end
end
def b
B.new
end
# etc
end
I would like to create a mixin of some sort that automatically creates the
module methods as needed. So,
module M
include ClassMethods
class A
def initialize ; puts "A" ; end
end
class B
def initialize ; puts "B" ; end
end
# etc
end
would give same effect as above. Possible?
Thanks,
T.
module M
class A
def initialize ; puts "A" ; end
end
def a
A.new
end
class B
def initialize ; puts "B" ; end
end
def b
B.new
end
# etc
end
I would like to create a mixin of some sort that automatically creates the
module methods as needed. So,
module M
include ClassMethods
class A
def initialize ; puts "A" ; end
end
class B
def initialize ; puts "B" ; end
end
# etc
end
would give same effect as above. Possible?
Thanks,
T.