has_friendship 0.0.1 → 0.0.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: 09dac4489b7f7828bde6219447dd8298a0912960
4
- data.tar.gz: 17cc29519b2b5a10ca2d56ca157027883ed4834e
3
+ metadata.gz: b63298f12c937856534b768fd95c49f1ff657e2c
4
+ data.tar.gz: d1e9db82b9423243e31116c1f11069d7c5da4a87
5
5
  SHA512:
6
- metadata.gz: aae7d2e05e0177b5c04efef5d925b0693a6f92d4735c41f070b8ef1e593aaa4c01a766efe71490c1cfaecf7367279329f0a8e375584f796a2e6df2d1da3396a2
7
- data.tar.gz: 8ba610fe77f4f12dc557afd60a158133f8b4279f22325baf3b1f037941e98b73d52192c2b0f5375a044ad4c9f7649c8823a9fe979c7c7590292379cdcf497683
6
+ metadata.gz: 96074edc5f0ffaf553834f17b614073146119219396537f6e6a8ac8a5a4ed4033419c890d47640eafd4d3487701076f656a9057cde3bb2acc36b9103fe1628fd
7
+ data.tar.gz: 264da3453b7604792f08b947d69a79d712e43b65af1efaac2572a1f0ab5f28af187110367ac6f2255ccb16d3a938522fd7e052043bb5b9195327762a3d4d427f
@@ -6,10 +6,10 @@ module HasFriendship
6
6
  end
7
7
 
8
8
  def has_friendship
9
-
9
+
10
10
  class_eval do
11
11
  has_many :friendships, as: :friendable, class_name: "HasFriendship::Friendship", dependent: :destroy
12
- has_many :friends,
12
+ has_many :friends,
13
13
  -> { where friendships: { status: 'accepted' } },
14
14
  through: :friendships
15
15
 
@@ -69,6 +69,10 @@ module HasFriendship
69
69
  end
70
70
  end
71
71
 
72
+ def friends_with?(friend)
73
+ HasFriendship::Friendship.where(friend_id: friend.id, status: 'accepted').present?
74
+ end
75
+
72
76
  end
73
77
  end
74
- end
78
+ end
@@ -10,7 +10,7 @@ module HasFriendship
10
10
  end
11
11
 
12
12
  def self.find_friendship(friendable, friend)
13
- HasFriendship::Friendship.find_by(friendable_id: friendable.id, friendable_type: friendable.class.base_class.name, friend_id: friend.id)
13
+ find_by(friendable_id: friendable.id, friendable_type: friendable.class.base_class.name, friend_id: friend.id)
14
14
  end
15
15
  end
16
- end
16
+ end
@@ -1,3 +1,3 @@
1
1
  module HasFriendship
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.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.0.1
4
+ version: 0.0.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: 2014-12-02 00:00:00.000000000 Z
11
+ date: 2015-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: byebug
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  description:
112
126
  email:
113
127
  - mikeswcho@gmail.com
@@ -124,7 +138,6 @@ files:
124
138
  - lib/has_friendship/friendable.rb
125
139
  - lib/has_friendship/friendship.rb
126
140
  - lib/has_friendship/version.rb
127
- - lib/tasks/has_friendship_tasks.rake
128
141
  homepage: https://github.com/sungwoncho/has_friendship
129
142
  licenses:
130
143
  - MIT
@@ -145,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
158
  version: '0'
146
159
  requirements: []
147
160
  rubyforge_project:
148
- rubygems_version: 2.4.4
161
+ rubygems_version: 2.4.7
149
162
  signing_key:
150
163
  specification_version: 4
151
164
  summary: Add social network friendship features to your Active Record models.
@@ -1,4 +0,0 @@
1
- # desc "Explaining what the task does"
2
- # task :has_friendship do
3
- # # Task goes here
4
- # end