General question about Ruby singleton class
        Posted  
        
            by Dex
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Dex
        
        
        
        Published on 2010-06-18T07:48:46Z
        Indexed on 
            2010/06/18
            15:23 UTC
        
        
        Read the original article
        Hit count: 349
        
module MyModule 
  def my_method; 'hello'; end
end
class MyClass 
  class << self
    include MyModule
  end 
end
MyClass.my_method   # => "hello
I'm unsure why "include MyModule" needs to be in the singleton class in order to be called using just MyClass.
Why can't I go:
X = MyClass.new
X.my_method
© Stack Overflow or respective owner