Skip to content

Instantly share code, notes, and snippets.

@sco
Created February 17, 2011 19:13
Show Gist options
  • Save sco/832414 to your computer and use it in GitHub Desktop.
Save sco/832414 to your computer and use it in GitHub Desktop.
Simple chronologic example
# Get an instance of the Chronologic client
chronologic = Chronologic::Client.new
# Cache metadata for users, spots, etc.
chronologic.object(:user_1, {:name => 'Scott Raymond'})
chronologic.object(:user_2, {:name => 'Josh Williams'})
chronologic.object(:spot_1, {:name => 'Gowalla HQ'})
# Create subscriptions when one user follows another, etc.
chronologic.subscribe(:user_2_friends, :user_1)
# Record a check-in, and distribute it to all relevant timelines
chronologic.event(
:key => :checkin_1,
:created_at => Time.now,
:data => { :type => 'checkin', :id => '1', :message => 'Here I am!' },
:timelines => [:user_1, :spot_1],
:subscribers => [:user_1],
:objects => { :user => :user_1, :spot => :spot_1 }
)
# Request a timeline of all check-ins at a spot
chronologic.timeline(:spot_1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment