title: Implementing ActiveRecord-like associations for an API wrapper
body: <p>I recently wrote <a href="https://github.com/adelevie/parse_resource" rel="nofollow">ParseResource</a>, which is a Ruby API wrapper for <a href="http://parse.com" rel="nofollow">Parse.com's</a> REST api.</p>
  
  <p>Here's a some basic usage:</p>
  
  <pre><code>class Post &lt; ParseResource
    fields :title, :author, :body
  end
  p = Post.create(:title =&gt; "Hello world", :author =&gt; "Alan", :body =&gt; "ipso lorem")
  </code></pre>
  
  <p>The project is fairly young, and a feature I really want to implement is associations. Something like this:</p>
  
  <pre><code>class Author &lt; ParseResource
    has_many :posts
    fields :name, :email
  end
  class Post &lt; ParseResource
    belongs_to :author
    fields :title, :body
  end
  a = Author.create(:name =&gt; "Alan", :email =&gt; "alan@example.com")
  p = Post.create(:title =&gt; "Associated!", :body =&gt; "ipso lorem", :author =&gt; a)
  p.author.class #=&gt; Author
  p.author.name #=&gt; "Alan"
  a.posts #=&gt; an array of Post objects
  </code></pre>
  
  <p>I'd love any advice, pointers, and pitfalls from anyone who has implemented something similar as well as from anyone who has a grasp of Parse's REST API.</p>