Created
December 16, 2011 20:56
-
-
Save paul/1487935 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
post = Post.detect { |p| p.author == some_author } # GET /posts?author_href=/authors/1234 | |
posts = Post.select { |p| p.q == "Stuff" } # GET /posts?q=Stuff | |
posts = Post.select { |p| p.title == "Stuff" } # GET /posts (since `title` isn't an available query param, fall back to Enumerable#select) | |
post = Post.get("http://api.ls.com/posts/1") | |
posts = Post.get_collection("http://api.ls.com/posts/1") | |
posts = Post.get_collection(Service.discover("AllPosts")) | |
posts = Post.get_collection() # auto-discovers based on service_name/uri | |
# Given service_uri = /posts{?author_href} | |
posts = Post.select { |p| p.author_href == "/authors/1" } # GET /posts?author_href=/authors/1 | |
posts = Post.select { |p| p.title == "test" } # GET /posts, with block forwarded to Enumerable#select | |
comments = Post.comments.select { |c| c.author_href = "/authors/1" } # GET /posts/1/comments?author_href=/authors/1 | |
comments = Comment.get_collection(post.comments_href).select { |c| ... } # Equivalent to above |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment