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
module Foo
class Bar
def foo
puts "erik is a dummy"
end
end
end
Foo::Bar.new.foo
=> erik is a dummy
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With