Created
March 9, 2009 06:56
-
-
Save jcrosby/76145 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
require 'cloudkit' | |
# use the default in-memory store | |
CloudKit.setup_storage_adapter | |
# create a resource in the 'items' collection | |
resource = CloudKit::Resource.create( | |
CloudKit::URI.new('/items'), | |
JSON.generate({:foo => 'bar'})) | |
# update the resource, automatically archiving the previous version | |
resource.update(JSON.generate({:foo => 'baz'})) | |
# get the raw JSON string | |
resource.json | |
# get the JSON as a ruby object | |
resource.parsed_json | |
# list all versions | |
resource.versions | |
# delete the resource, automatically archiving it | |
resource.delete | |
# find all resources for a user | |
CloudKit::Resource.all(:remote_user => 'http://joncrosby.me') | |
# find all current 'items' | |
CloudKit::Resource.current(:collection_reference => '/items') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment