title: How to dynamically call accessor methods in Ruby
body: <p>Regardless of whether it's good practice or not, how can I dynamically call accessor methods in Ruby?</p>
  
  <p>Here's an example class:</p>
  
  <pre><code>class Test_Class
    attr_accessor :a, :b
  end
  </code></pre>
  
  <p>I can use the Object.send method to read the variable...</p>
  
  <pre><code>instance.a = "value"
  puts( instance.send( "a" ) )
  # =&gt; value
  </code></pre>
  
  <p>But I'm having a hard time trying to write to it. These throw "wrong number of arguments (1 for 0) (ArgumentError)"</p>
  
  <pre><code>instance.send("a", "value")
  </code></pre>
  
  <p>and</p>
  
  <pre><code>instance.method("a").call("value")
  </code></pre>
  
  <p>Please help me StackOverflow!</p>