title: Why is my class variable being re-initialized using cattr_accessor (JRuby, Rails)
body: <p>OK, I know this is a bit of a frankenstack, but I am running JRuby on Rails, and I'm relatively new to both.  I'm seeing some behavior that I can't understand, and I'd like to know if I'm doing something wrong or if its a problem with my stack.  The basic issue is that it appears that my class attributes are being reinitialized, something that I wouldn't expect to ever happen.</p>
  
  <p>Here's essentially my code</p>
  
  <pre><code>class MyController &lt; ActionController::Base
    cattr_accessor :an_attr
    before_filter :init_an_attr
  
    def init_an_attr
      if @@an_attr.nil? 
        @@an_attr = {}
      end
      # do some other stuff here
    end
  end
  </code></pre>
  
  <p>The problem lies in the fact that every time init_an_attr is called, the condition on the if evaluates to true, and I end up reassigning @@an_attr.</p>
  
  <p>Is that the expected behavior?  If so can you explain why, because to me, the assignment should only happen once.</p>