Created
October 17, 2012 19:15
-
-
Save roychri/3907506 to your computer and use it in GitHub Desktop.
Instance method of a class in a module to create an instance of the includer's class.
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 Foo | |
class C | |
def bar | |
self.new # I want this to return an object of type Fubar | |
end | |
end | |
end | |
class Fubar | |
include Foo | |
def self.foo | |
C.new | |
end | |
end | |
f = Fubar.foo.bar # f would be an instance of Fubar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment