Why aren't module methods availiable as class methods when a module is
included?
For example:
module Foo
def Foo.bar; end
end
class A
include Foo
end
A.bar #=> NameError: undefined method `bar' for A:Class
I'd like my module to add instance methods as well as class methods,
with a single include statement.
To do that I splitted the module: one with instance methods and the
other one with module/class methods:
module Foo_class_methods
def bar; puts "Foo.bar"; end
end
module Foo
def bar; puts "Foo#bar"; end
def Foo.append_features(mod)
super
mod.extend Foo_class_methods
end
end
class A
include Foo
end
A.bar #=> Foo.bar
A.new.bar #=> Foo#bar
Is there a better way to acheive that? It looks better if there is only
one module.
Mike.
midulo.