title: What happens when attr_accessor is within a class method?
body: <p>So this came up to my mind and wonder what happens when some thing below is done.</p>
  
  <pre><code> class Test 
     def self.abc
       attr_accessor :John 
     end
   end
  
   object = Test.new
   puts "before calling class method abc:  #{object.class.instance_methods(false)}"
   Test.abc
   puts "after calling class method abc:   #{object.class.instance_methods(false)}"
  </code></pre>
  
  <p>Here what I checked was, do the getter and setter methods get created in this way. And if so, are those instance methods or class methods. First I create a new object and then I view what are the instance methods of that object. After that in next line I run the <code>class</code> method <code>abc</code> and then again, I check for instance methods of <code>object</code>. At that time only I can see the two methods <code>John</code> and <code>John=</code>. How does this happen ? How come a running of a class method dynamically add methods to already created objects?. Can somebody please explain me this.</p>
  
  <p>The output of the code was:</p>
  
  <pre><code>before calling class method abc:  []
  after calling class method abc:   [:John, :John=]
  </code></pre>