Sha256: f848f6a0f36484cbc2d85f644e5c430b15a4ba21f8723f68441ba24c95b8c5cc

Contents?: true

Size: 831 Bytes

Versions: 1

Compression:

Stored size: 831 Bytes

Contents

class <%= user_class_name %> < ActiveRecord::Base

  def followed_by?(user)
    <%=friendship_class_name%>.followed_by?(self.username, user.username)
  end

  def follows?(user)
    <%=friendship_class_name%>.follows?(self.username, user.username)
  end

  def follow!(user)
    return false if self.username == user.username
    <%=friendship_class_name%>.follow!(self.username, user.username)
    true
  end
  
  def unfollow!(user)
    <%=friendship_class_name%>.unfollow!(self.username, user.username)
  end

  
  def followers
    followers = <%= friendship_class_name %>.followers_for(self.username)
    <%= user_class_name %>.where(:username => followers)
  end

  def followings
    followings = <%= friendship_class_name %>.followings_for(self.username)
    <%= user_class_name %>.where(:username => followings)
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
redis-friendships-0.2 lib/generators/redis_friendships/templates/user.rb