Browse files

updated readme

  • Loading branch information...
1 parent f331547 commit 6d41a3d6c620830f98b2ef90a72e694232c93039 @clayallsopp committed May 8, 2012
Showing with 27 additions and 3 deletions.
  1. +27 −3
@@ -59,8 +59,8 @@ user = User.find(1) do |user|
# Later...
-=> [#<Question @answers=[#<Answer>, #<Answer>] @user=#<User>,
- #<Question @answers=[#<Answer>, #<Answer>] @user=#<User>]
+=> [#<Question @user=#<User>,
+ #<Question @user=#<User>]
Here's what our files look like:
@@ -102,4 +102,28 @@ class Question < RemoteModule::RemoteModel
+## How?
+RemoteModel is designed for JSON apis which return structures with "nice" properties.
+When you make a request with a RemoteModel (self.get/put/post/delete), the result is always parsed as JSON. The ActiveRecord-esque methods take this JSON and create objects out of it. It's clever and creates the proper associations (belongs_to/has_one/has_many) within the objects, as defined in the models.
+#### FormatableString
+The AR methods also use the member/collection defined URLs to make requests. These URLs are a string which you can use :symbols to input dynamic values. These strings can be formatted using a hash and/or taking an object (it will look to see if the object responds to these symbols and call the method if applicable):
+>> s ="url/:param")
+=> "url/:param"
+>> s.format({param: 6})
+=> "url/6"
+RemoteModels can define custom urls and call those as methods (see question.rb above).
+## Todo
+- More tests
+- CoreData integration

0 comments on commit 6d41a3d

Please sign in to comment.