has_friendship 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 50065c83e6fa815a565ce0011363dee9f2b84112
4
- data.tar.gz: c49fd71f89811cb8dbb69c37343d21ad2d0b20ce
3
+ metadata.gz: 30912406c5bb74e24220261df7b201a733cf17c8
4
+ data.tar.gz: e03fffdc28479f2e4a854d2fe325f960945b7538
5
5
  SHA512:
6
- metadata.gz: 7ae61ed59f8998c28ec53a24e57736341d8eef93c2b2ecacc7da8618e8ae5d32c5b146ad9cc1039f5adacbf69d4ade054419bfef6f6d63863a5d84c6fd691261
7
- data.tar.gz: 47d40f00541f16b31f0970fc459110da505cd0cb73d7e2c12fcf5648384f10dd3d399959cc3cedbbd565fa949bb92aae4fab1026414ddafc94a7fded50eb38a9
6
+ metadata.gz: cf4dae8e5fafc0a1fafdca3dd4ea37bfc13b0675426f33ce1e749356681c8ead432c72e6fcc32ba7feacd796e6e205e1f9591e8b95919457a7634ae920266a14
7
+ data.tar.gz: e34d36ee0924adbd0e9d97bee1a40e18209126935a12b1ddd03336139bbb31ad3fb9660ce0ef8b2195790c3c18dd6ba8a9f1a066e21088912f193582afba0e18
@@ -85,7 +85,7 @@ module HasFriendship
85
85
  end
86
86
 
87
87
  def friends_with?(friend)
88
- HasFriendship::Friendship.find_relation(self, friend).any?
88
+ HasFriendship::Friendship.find_relation(self, friend, status: 'accepted').any?
89
89
  end
90
90
 
91
91
  private
@@ -1,11 +1,17 @@
1
1
  module HasFriendship
2
2
  class Friendship < ActiveRecord::Base
3
- def self.relation_attributes(one, other)
4
- {
3
+ def self.relation_attributes(one, other, status: nil)
4
+ attr = {
5
5
  friendable_id: one.id,
6
6
  friendable_type: one.class.base_class.name,
7
7
  friend_id: other.id
8
8
  }
9
+
10
+ if status
11
+ attr[:status] = status
12
+ end
13
+
14
+ attr
9
15
  end
10
16
 
11
17
  def self.create_relation(one, other, options)
@@ -14,8 +20,8 @@ module HasFriendship
14
20
  relation.save
15
21
  end
16
22
 
17
- def self.find_relation(friendable, friend)
18
- where relation_attributes(friendable, friend)
23
+ def self.find_relation(friendable, friend, status: nil)
24
+ where relation_attributes(friendable, friend, status: status)
19
25
  end
20
26
 
21
27
  def self.exist?(friendable, friend)
@@ -1,3 +1,3 @@
1
1
  module HasFriendship
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_friendship
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sung Won Cho
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-20 00:00:00.000000000 Z
11
+ date: 2016-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails