-
Notifications
You must be signed in to change notification settings - Fork 71
Listing friends
raw1z edited this page Mar 6, 2012
·
1 revision
There are two types of friends in amistad :
- the friends who were invited by the user
- the friends who invited the user
To get the friend who where invited by @john, use the invited() method :
@john.invited #=> [@jane]
To get the friends who invited @john, use the invited_by() method :
@john.invited_by #=> [@peter]
To get all the friends of @john (those he invited and those who invited him) :
@john.friends #=> [@jane, @peter]
To get the pending friendships use :
@victoria.pending_invited #=> [@john]
@john.pending_invited_by #=> [@victoria]
It is also possible to check if two users are friends :
@john.friend_with? @jane #=> true
@victoria.friend_with? @john #=> false
You can also check if a user is somehow connected to another :
@john.connected_with? @jane #=> true
@victoria.connected_with? @john #=> true
You can also check if a user was invited by another :
@john.invited_by? @john #=> true
@victoria.invited_by? @john #=> false
You can also check if a user invited another :
@john.invited? @jane #=> true
You can also find the friends that two users have in common :
@john.common_friends_with(@peter) #=> [@jane]