Module: Related::Follower

Defined in:
lib/related/follower.rb

Instance Method Summary collapse

Instance Method Details

#follow!(other) ⇒ Object



3
4
5
# File 'lib/related/follower.rb', line 3

def follow!(other)
  Related::Relationship.create(:follow, self, other)
end

#followed_by?(other) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/related/follower.rb', line 24

def followed_by?(other)
  self.followers.include?(other)
end

#followersObject



12
13
14
# File 'lib/related/follower.rb', line 12

def followers
  self.incoming(:follow)
end

#followers_countObject



32
33
34
# File 'lib/related/follower.rb', line 32

def followers_count
  self.followers.size
end

#followingObject



16
17
18
# File 'lib/related/follower.rb', line 16

def following
  self.outgoing(:follow)
end

#following?(other) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/related/follower.rb', line 28

def following?(other)
  self.following.include?(other)
end

#following_countObject



36
37
38
# File 'lib/related/follower.rb', line 36

def following_count
  self.following.size
end

#friendsObject



20
21
22
# File 'lib/related/follower.rb', line 20

def friends
  self.followers.intersect(self.following)
end

#unfollow!(other) ⇒ Object



7
8
9
10
# File 'lib/related/follower.rb', line 7

def unfollow!(other)
  rel = self.following.relationships.find(other)
  rel.destroy if rel
end