Skip to content

Instantly share code, notes, and snippets.

@jcrosby
Created March 9, 2009 06:56
Show Gist options
  • Save jcrosby/76145 to your computer and use it in GitHub Desktop.
Save jcrosby/76145 to your computer and use it in GitHub Desktop.
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