title: Calling a module function in a ruby module
body: <p>I want to call a module function to define a constant in a utility module in ruby. However, when I try this I get an error message. Here comes the code and the error:</p>
  
  <pre><code>module M
    ABC = fun
  
    module_function
  
    def self.fun
      "works"
    end
  end
  </code></pre>
  
  <p>Error message: </p>
  
  <pre><code>NameError: undefined local variable or method `fun' for M:Module
  </code></pre>
  
  <p>Any ideas? I also tried it without <code>self</code> and with <code>M.fun</code> but no success...</p>