Module: Related::Follower
- Defined in:
- lib/related/follower.rb
Instance Method Summary collapse
- #follow!(other) ⇒ Object
- #followed_by?(other) ⇒ Boolean
- #followers ⇒ Object
- #followers_count ⇒ Object
- #following ⇒ Object
- #following?(other) ⇒ Boolean
- #following_count ⇒ Object
- #friends ⇒ Object
- #unfollow!(other) ⇒ Object
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
24 25 26 |
# File 'lib/related/follower.rb', line 24 def followed_by?(other) self.followers.include?(other) end |
#followers ⇒ Object
12 13 14 |
# File 'lib/related/follower.rb', line 12 def followers self.incoming(:follow) end |
#followers_count ⇒ Object
32 33 34 |
# File 'lib/related/follower.rb', line 32 def followers_count self.followers.size end |
#following ⇒ Object
16 17 18 |
# File 'lib/related/follower.rb', line 16 def following self.outgoing(:follow) end |
#following?(other) ⇒ Boolean
28 29 30 |
# File 'lib/related/follower.rb', line 28 def following?(other) self.following.include?(other) end |
#following_count ⇒ Object
36 37 38 |
# File 'lib/related/follower.rb', line 36 def following_count self.following.size end |
#friends ⇒ Object
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 |