acts_as_friendable 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/README.md +4 -4
- data/lib/acts_as_friendable.rb +1 -1
- data/lib/acts_as_friendable/CHANGELOG.md +7 -0
- data/lib/acts_as_friendable/model_additions.rb +14 -16
- data/lib/acts_as_friendable/version.rb +1 -1
- metadata +9 -3
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -8,13 +8,13 @@ ActsAsFriendable defines a "friendship" as a two-way relationship which is initi
|
|
8
8
|
|
9
9
|
## Installation
|
10
10
|
|
11
|
-
Add ActsAsFriendable to
|
11
|
+
Add ActsAsFriendable to your Gemfile:
|
12
12
|
|
13
13
|
```ruby
|
14
14
|
gem 'acts_as_friendable'
|
15
15
|
```
|
16
16
|
|
17
|
-
And then
|
17
|
+
And then install it with bundler by executing:
|
18
18
|
|
19
19
|
```shell
|
20
20
|
bundle install
|
@@ -50,9 +50,9 @@ Given the "friendship" definition in the Overview, we have 4 possible states of
|
|
50
50
|
|
51
51
|
States #1 and #2 are simply what we will be calling "friends." They are approved relationships, no matter the direction. Because we don’t care who requested the friendship once it’s approved, we will group these together.
|
52
52
|
|
53
|
-
State #3 is what we call "pending friends." Other users whom the current user has requested to be friends
|
53
|
+
State #3 is what we call "pending friends." Other users with whom the current user has requested to be friends and are awaiting approval. These are out of of the control of the current user and just waiting to be approved or rejected.
|
54
54
|
|
55
|
-
State #4 is what we call "requested friends." Other
|
55
|
+
State #4 is what we call "requested friends." Other users who have requested that the current user be their friend and are awaiting the approval of the current user. These are the actionable items for the current user to approve or reject. Ignoring a friend request simply deletes the non-approved Friendship (similar to Facebook). It doesn't tell the the other person they were reject but allows them to send another friend request if they want.
|
56
56
|
|
57
57
|
With that understanding we have the following scopes / "lookup" methods available to us:
|
58
58
|
|
data/lib/acts_as_friendable.rb
CHANGED
@@ -5,25 +5,23 @@ module ActsAsFriendable
|
|
5
5
|
|
6
6
|
end
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
8
|
+
def friends
|
9
|
+
direct_friends | inverse_friends
|
10
|
+
end
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
def friend_ids
|
13
|
+
friends.map {|f| f.id}
|
14
|
+
end
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
def friend_ids_and_me
|
17
|
+
friend_ids << id
|
18
|
+
end
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
20
|
+
def pending_and_friend_ids
|
21
|
+
pending_and_friend_ids = []
|
22
|
+
pending_and_friend_ids << friend_ids
|
23
|
+
pending_and_friend_ids << pending_friends.map {|f| f.id}
|
24
|
+
pending_and_friend_ids.flatten
|
27
25
|
end
|
28
26
|
|
29
27
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_friendable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-04-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -109,6 +109,7 @@ files:
|
|
109
109
|
- Rakefile
|
110
110
|
- acts_as_friendable.gemspec
|
111
111
|
- lib/acts_as_friendable.rb
|
112
|
+
- lib/acts_as_friendable/CHANGELOG.md
|
112
113
|
- lib/acts_as_friendable/friendships.rb
|
113
114
|
- lib/acts_as_friendable/model_additions.rb
|
114
115
|
- lib/acts_as_friendable/version.rb
|
@@ -135,12 +136,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
135
136
|
- - ! '>='
|
136
137
|
- !ruby/object:Gem::Version
|
137
138
|
version: '0'
|
139
|
+
segments:
|
140
|
+
- 0
|
141
|
+
hash: 1283071857139746599
|
138
142
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
143
|
none: false
|
140
144
|
requirements:
|
141
145
|
- - ! '>='
|
142
146
|
- !ruby/object:Gem::Version
|
143
147
|
version: '0'
|
148
|
+
segments:
|
149
|
+
- 0
|
150
|
+
hash: 1283071857139746599
|
144
151
|
requirements: []
|
145
152
|
rubyforge_project:
|
146
153
|
rubygems_version: 1.8.23
|
@@ -155,4 +162,3 @@ test_files:
|
|
155
162
|
- spec/config/schema.rb
|
156
163
|
- spec/generators/install_generator_spec.rb
|
157
164
|
- spec/spec_helper.rb
|
158
|
-
has_rdoc:
|