title: How to dynamically define a class method which will refer to a local variable outside?
body: <pre><code>class C
  end
  
  var = "I am a local var outside"
  
  C.class_eval do
     def self.a_class_method
       puts var 
     end
  end
  </code></pre>
  
  <p>I know, this is not correct, because the <code>def</code> created a new scope.
  I also know that use <code>define_method</code> can create a instance method without creating a new scope, but my point is how to define a <strong>class method</strong>.</p>