Skip to content

Instantly share code, notes, and snippets.

@roychri
Created October 17, 2012 19:15
Show Gist options
  • Save roychri/3907506 to your computer and use it in GitHub Desktop.
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.
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