title: How do I use hash keys as methods on a class?
body: <p>I have a class and a hash. How can I get the members of the hash to dynamically become methods on the class with the key as the method name?</p>
  
  <pre><code>class User
    def initialize
      @attributes = {"sn" =&gt; "Doe", "givenName" =&gt; "John"}
    end
  end
  </code></pre>
  
  <p>For example, I would like to be able to have the following output <code>Doe</code>:</p>
  
  <pre><code>u = User.new
  puts u.sn
  </code></pre>