title: Preventing conflict with module-specific instance variables
body: <p>I have a mixin that can show up in several different areas of our codebase.  In a couple of cases there is, or was, an edge case where the module's use of instance variables conflicted with instance variables used by the classes.</p>
  
  <p>Prepending variable names @__like_this was one solution, but the other we came up with was more sophisticated, having this general structure, in which the accessor methods are closures:</p>
  
  <pre><code>module HiddenValue
    def initialize
      hidden_value = nil
      define_singleton_method :value, -&gt;() { hidden_value }
      define_singleton_method :value=, -&gt;(v) { hidden_value = v }
      super
    end
  end
  
  class RealClass
    include HiddenValue
    # [...]
  end
  
  foo = RealClass.new
  foo.value = 123
  foo.value # =&gt; 123
  </code></pre>
  
  <p>Is this bad style? It means that all methods wanting direct access to the variable must be defined dynamically inside <code>initialize</code>, and that could get ugly.  Is there a cleaner way? Or is this the closest we'll get to a module-level "lexical"-ish scoped instance variable?</p>