title: ruby module_function vs including module
body: <p>In ruby, I understand that module functions can be made available without mixing in the module by using <code>module_function</code> as shown here. I can see how this is useful so you can use the function without mixing in the module.</p>
  
  <pre><code>module MyModule
    def do_something
      puts "hello world"
    end
    module_function :do_something
  end
  </code></pre>
  
  <p>My question is though why you might want to have the function defined both of these ways.</p>
  
  <p>Why not just have</p>
  
  <pre><code>def MyModule.do_something
  </code></pre>
  
  <p>OR</p>
  
  <pre><code>def do_something
  </code></pre>
  
  <p>In what kind of cases would it be useful to have the function available to be mixed in, or to be used as a static method?</p>