Reputation: 2357
I want to note that this is COMPLETELY a made up question. I am aware that there are other ways to accomplish this.
I want to declare a module like so
module Foo
# some logic here to
# get instance method 'foo' on
# a later defined class
end
then later I want to declare a class like:
class Foo::Bar
end
Then WITHOUT using include or extend be able to do this:
Foo::Bar.new.foo
and have it call the foo method I defined in module Foo
Upvotes: 3
Views: 94
Reputation: 5182
module Foo
class Bar
def foo
puts "erik is a dummy"
end
end
end
Foo::Bar.new.foo
=> erik is a dummy
Upvotes: 2