has_friendship 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/has_friendship/friendable.rb +1 -1
- data/lib/has_friendship/friendship.rb +10 -4
- data/lib/has_friendship/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30912406c5bb74e24220261df7b201a733cf17c8
|
4
|
+
data.tar.gz: e03fffdc28479f2e4a854d2fe325f960945b7538
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf4dae8e5fafc0a1fafdca3dd4ea37bfc13b0675426f33ce1e749356681c8ead432c72e6fcc32ba7feacd796e6e205e1f9591e8b95919457a7634ae920266a14
|
7
|
+
data.tar.gz: e34d36ee0924adbd0e9d97bee1a40e18209126935a12b1ddd03336139bbb31ad3fb9660ce0ef8b2195790c3c18dd6ba8a9f1a066e21088912f193582afba0e18
|
@@ -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)
|
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.
|
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-
|
11
|
+
date: 2016-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|