popular 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NWE5Mjc5N2Q5YjVlNzc2OTM5ODM0MjdlYzkwNmJlOWQ1NTI5MGQ1Mg==
4
+ NWQyNWFkOTY3ZjlhNTY0Y2JhZTFmZjM4NGUxNmQ1YjZjZjhlYmRkMg==
5
5
  data.tar.gz: !binary |-
6
- ZTdhZGY1MjM0MDdhNjM5NDZhODhiNTRkNzYwOTMzODRlY2EyNjM4OQ==
6
+ ODhhNmU2ZDc1ODU0NGU2YjU1Zjc0ZjU1YjFjYWQyZTlhMmIyNDkwMg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OWJjMTBiYjRlOGNkN2NhMmQxYjEyYWJiZGNmOWNkYmQ2ZDhmYTQzOWZkODgw
10
- YTk5MWE1ZTFkMzNkZTliMmNkYTE1ZGUxYzE2YzJjMzNjODllNTUzNDAzODM4
11
- YTE3MzNhMTRhNWMzOGVmOTliMDlhZjExNWJlMDA4OGYwZTY4ZTk=
9
+ M2NjNzI0MGY5NTQyZGYxNDZiNGJjMDZhZWQ4YmIxYWI2MDM5YTY3MjhiZDkx
10
+ MzhjYzM5ZjNhYzA1OWQzN2Y2ZTc2NTFiN2U1NDMyZGRjZTViNTk0NTgxMDcw
11
+ MTlkZmRhZDM4NzAxYjQyMWRhNGYzY2QwODRiN2EwZTAyOWM2MWE=
12
12
  data.tar.gz: !binary |-
13
- ZWM0NGMwM2RjOGY3N2Y0NjE5OGQ3MDc1ZTcyNmI0N2Y2MzA1MjFlZWE0ZDg2
14
- YjNmZjQ2ZmEyMjhiZDg3ZGM3YmFjZmM2MzJjYzk5ZWUxYTgzNjRjMTlmZGRl
15
- NzY4ODI4YTBiZTM5ZTU2NWZlNThhNzJhNmIyMTBhM2NlNTZmNTA=
13
+ YjJmYmNkZGQxYzA2Zjk4NjJjZDcyNjU3YzIyOTEwMjhhYjk0OGVmMDJiOWY3
14
+ NzUzNTk4ZjE3ZmVhYTA4MzM1NWIyZmUxMDc5NTAyMzA5MjU2NjA0NWE3ZGE1
15
+ NGI2NmFjNzk3MzBmNTQ0ZjczMWU0NzlmMTQzOTc3MmRiNDM0ZTM=
data/README.md CHANGED
@@ -45,13 +45,20 @@ end
45
45
  @jackson = User.create name: "Jackson"
46
46
 
47
47
  # Adding and removing friends
48
- @sam.friends_with? @jackson #=> false
49
- @sam.friends.length #=> 0
48
+ @sam.friends_with? @jackson #=> false
49
+ @sam.friended_by? @jackson #=> false
50
+
50
51
  @sam.befriend @jackson
51
- @sam.friends_with? @jackson #=> true
52
- @sam.friends.length #=> 1
52
+ @sam.friends_with? @jackson #=> true
53
+
53
54
  @sam.unfriend @jackson
54
- @sam.friends_with? @jackson #=> false
55
+ @sam.friends_with? @jackson #=> false
56
+
57
+ @jackson.befriend @sam
58
+ @sam.friended_by? @jackson #=> true
59
+
60
+ @sam.befriend @jackson
61
+ @sam.mutual_friends_with? @jackson #=> true
55
62
  ```
56
63
 
57
64
  ### Callbacks
@@ -68,6 +68,26 @@ module Popular
68
68
  end
69
69
  end
70
70
 
71
+ # Helper method for determining whether instances are mutual friends
72
+ #
73
+ # @param [Object] popular_model
74
+ # @return [Boolean] if both instances have befriended eachother
75
+ #
76
+ # @example
77
+ # user = User.create name: "Justin"
78
+ # other_user = User.create name: "Jenny"
79
+ #
80
+ # user.befriend other_user
81
+ # other_user.befriend user
82
+ #
83
+ # user.mutual_friends_with? other_user #=> true
84
+ def mutual_friends_with? popular_model
85
+ friends_with?( popular_model ) && friended_by?( popular_model )
86
+ end
87
+
88
+ # Helper method for finding whether or not the instance has befriended
89
+ # another given popular_model
90
+ #
71
91
  # Helper method for finding whether or not the instance has
72
92
  # been befriended by another given popular_model
73
93
  #
@@ -1,3 +1,3 @@
1
1
  module Popular
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
@@ -6,6 +6,17 @@ shared_examples "a popular model" do
6
6
 
7
7
  expect( popular_model ).to be_friended_by another_popular_model
8
8
  end
9
+
10
+ it '#mutual_friends_with? returns false if instances are not mutual friends' do
11
+ expect( popular_model ).to_not be_mutual_friends_with another_popular_model
12
+ end
13
+
14
+ it '#mutual_friends_with? returns true if instances have befriended eachother' do
15
+ popular_model.befriend another_popular_model
16
+ another_popular_model.befriend popular_model
17
+
18
+ expect( popular_model ).to be_mutual_friends_with another_popular_model
19
+ end
9
20
  end
10
21
 
11
22
  describe '.befriend!' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: popular
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - thejchap