are you looking for that here?
module MixInClassMethods
def test
puts "test"
end
end
try using 'extend'
class MyClass
extend MixInClassMethods
end
> MyClass.test
"test"
Andrew Stone schrieb:
> I've read most of this thread and still am a little confused. I'm no
> ruby
> guru by any stretch of the imagination, but I use modules to house
> code that
> can be utilized in various classes. If I need class methods then I use
> inheritance. IMO, this is simple and clean.
>
> So far, there doesn't seem to be a clean/simple way to have mixin support
> for class methods. Until that epiphany is reached, I would think it
> would
> be better to leave things as is.
>
> I will give a novice suggestion:
>
> Maybe instead of trying to work in this feature to modules, why not
> introduce "ClassModule"? Or has this been said? This way it is clear
> what
> they use is and they can, in turn, have features specific to class method
> inheritance (if any are needed).
>
> Therefore you could mix and match ClassModules with regular Modules.
> Seems
> pretty flexible to me. I have no idea how difficult this would be to
> implement.
>