我最近寫了ParseResource,這是一個用於Parse.com's REST API的Ruby API封裝器。爲API封裝器實現類似於ActiveRecord的關聯
這裏的一些基本用法:
class Post < ParseResource
fields :title, :author, :body
end
p = Post.create(:title => "Hello world", :author => "Alan", :body => "ipso lorem")
該項目是相當年輕,而一個功能,我真的想實現的關聯。事情是這樣的:
class Author < ParseResource
has_many :posts
fields :name, :email
end
class Post < ParseResource
belongs_to :author
fields :title, :body
end
a = Author.create(:name => "Alan", :email => "[email protected]")
p = Post.create(:title => "Associated!", :body => "ipso lorem", :author => a)
p.author.class #=> Author
p.author.name #=> "Alan"
a.posts #=> an array of Post objects
我喜歡任何意見,指針和陷阱的人誰從人誰擁有解析的REST API的把握來實現類似的事情還有。
你聽說過[nulldb](https://github.com/nulldb/nulldb)嗎? –