1. Private singleton methods

    When creating singleton methods in classes and modules I prefer the def self.name notation since I think it’s more distinct, plus a few more reasons. The limitation of it is that it doesn’t allow to create private methods by default.

    module Mo
      private
    
      def self.private?
        "No!"
      end
    end
    
    >> Mo.private?
    => "No!"
    

    The solution is using class << self notation:

    module Mo
      class << self
        private
    
        def actually_private?
          "Oh yes... But you won't see this, I'm private you know..."
        end
      end
    end
    
    >> Mo.actually_private?
    NoMethodError: private method `actually_private?' called for Mo:Module