Skip to content

Instantly share code, notes, and snippets.

@unorthodoxgeek
Created October 22, 2011 10:15
Show Gist options
  • Save unorthodoxgeek/1305840 to your computer and use it in GitHub Desktop.
Save unorthodoxgeek/1305840 to your computer and use it in GitHub Desktop.
social graph ruby + redis
include Redis::Objects
counter :visits, :start => 0
counter :likes, :start => 0
set :following
set :followers
def follow( user )
self.following << user.id
user.followers << id
end
def unfollow( user )
self.following.delete( user.id )
user.followers.delete( id )
end
def following?( user )
self.following.include?( user.id )
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment