acts_as_amico 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +11 -0
- data/.rspec +2 -0
- data/.rvmrc +1 -0
- data/API.md +361 -0
- data/CHANGELOG.md +16 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +20 -0
- data/README.md +185 -0
- data/Rakefile +20 -0
- data/acts_as_amico.gemspec +28 -0
- data/lib/acts_as_amico/amico_user.rb +69 -0
- data/lib/acts_as_amico/railtie.rb +20 -0
- data/lib/acts_as_amico/version.rb +3 -0
- data/lib/acts_as_amico.rb +9 -0
- data/spec/amico/amico_user_spec.rb +700 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +9 -0
- data/spec/dummy/app/assets/stylesheets/application.css +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/models/admin.rb +11 -0
- data/spec/dummy/app/models/rest_object.rb +7 -0
- data/spec/dummy/app/models/thing.rb +3 -0
- data/spec/dummy/app/models/user.rb +3 -0
- data/spec/dummy/app/models/widget.rb +3 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config/application.rb +44 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +22 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +30 -0
- data/spec/dummy/config/environments/production.rb +60 -0
- data/spec/dummy/config/environments/test.rb +39 -0
- data/spec/dummy/config/initializers/amico.rb +14 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +58 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/migrate/20111114184611_create_users.rb +10 -0
- data/spec/dummy/db/migrate/20111114184654_create_admins.rb +10 -0
- data/spec/dummy/db/migrate/20111114184712_create_things.rb +10 -0
- data/spec/dummy/db/migrate/20111114184731_create_widgets.rb +10 -0
- data/spec/dummy/db/schema.rb +44 -0
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/factories/people.rb +12 -0
- data/spec/factories/stuff.rb +11 -0
- data/spec/spec_helper.rb +39 -0
- metadata +239 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use --create ruby-1.9.3@amico_gem
|
data/API.md
ADDED
@@ -0,0 +1,361 @@
|
|
1
|
+
```ruby
|
2
|
+
require 'amico'
|
3
|
+
=> true
|
4
|
+
|
5
|
+
Amico.configure do |configuration|
|
6
|
+
configuration.redis = Redis.new
|
7
|
+
configuration.namespace = 'amico'
|
8
|
+
configuration.following_key = 'following'
|
9
|
+
configuration.followers_key = 'followers'
|
10
|
+
configuration.blocked_key = 'blocked'
|
11
|
+
configuration.reciprocated_key = 'reciprocated'
|
12
|
+
configuration.pending_key = 'pending'
|
13
|
+
configuration.default_scope_key = 'default'
|
14
|
+
configuration.pending_follow = false
|
15
|
+
configuration.page_size = 25
|
16
|
+
end
|
17
|
+
|
18
|
+
Amico.follow(1, 11)
|
19
|
+
=> [1, 1]
|
20
|
+
|
21
|
+
Amico.following?(1, 11)
|
22
|
+
=> true
|
23
|
+
|
24
|
+
Amico.following?(11, 1)
|
25
|
+
=> false
|
26
|
+
|
27
|
+
Amico.follow(11, 1)
|
28
|
+
=> [1, 1]
|
29
|
+
|
30
|
+
Amico.following?(11, 1)
|
31
|
+
=> true
|
32
|
+
|
33
|
+
Amico.following_count(1)
|
34
|
+
=> 1
|
35
|
+
|
36
|
+
Amico.followers_count(1)
|
37
|
+
=> 1
|
38
|
+
|
39
|
+
Amico.unfollow(11, 1)
|
40
|
+
=> [1, 1]
|
41
|
+
|
42
|
+
Amico.following_count(11)
|
43
|
+
=> 0
|
44
|
+
|
45
|
+
Amico.following_count(1)
|
46
|
+
=> 1
|
47
|
+
|
48
|
+
Amico.follower?(1, 11)
|
49
|
+
=> false
|
50
|
+
|
51
|
+
Amico.following(1)
|
52
|
+
=> ["11"]
|
53
|
+
|
54
|
+
Amico.block(1, 11)
|
55
|
+
=> [1, 1, 1, 1, 1]
|
56
|
+
|
57
|
+
Amico.following?(11, 1)
|
58
|
+
=> false
|
59
|
+
|
60
|
+
Amico.blocked?(1, 11)
|
61
|
+
=> true
|
62
|
+
|
63
|
+
Amico.unblock(1, 11)
|
64
|
+
=> true
|
65
|
+
|
66
|
+
Amico.blocked?(1, 11)
|
67
|
+
=> false
|
68
|
+
|
69
|
+
Amico.follow(11, 1)
|
70
|
+
=> nil
|
71
|
+
|
72
|
+
Amico.follow(1, 11)
|
73
|
+
=> [1, 1]
|
74
|
+
|
75
|
+
Amico.reciprocated?(1, 11)
|
76
|
+
=> true
|
77
|
+
|
78
|
+
Amico.reciprocated(1)
|
79
|
+
=> ["11"]
|
80
|
+
```
|
81
|
+
|
82
|
+
Use amico (with pending relationships for follow):
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
require 'amico'
|
86
|
+
=> true
|
87
|
+
|
88
|
+
Amico.configure do |configuration|
|
89
|
+
configuration.redis = Redis.new
|
90
|
+
configuration.namespace = 'amico'
|
91
|
+
configuration.following_key = 'following'
|
92
|
+
configuration.followers_key = 'followers'
|
93
|
+
configuration.blocked_key = 'blocked'
|
94
|
+
configuration.reciprocated_key = 'reciprocated'
|
95
|
+
configuration.pending_key = 'pending'
|
96
|
+
configuration.default_scope_key = 'default'
|
97
|
+
configuration.pending_follow = true
|
98
|
+
configuration.page_size = 25
|
99
|
+
end
|
100
|
+
|
101
|
+
Amico.follow(1, 11)
|
102
|
+
=> true
|
103
|
+
|
104
|
+
Amico.follow(11, 1)
|
105
|
+
=> true
|
106
|
+
|
107
|
+
Amico.pending?(1, 11)
|
108
|
+
=> true
|
109
|
+
|
110
|
+
Amico.pending?(11, 1)
|
111
|
+
=> true
|
112
|
+
|
113
|
+
Amico.accept(1, 11)
|
114
|
+
=> nil
|
115
|
+
|
116
|
+
Amico.pending?(1, 11)
|
117
|
+
=> false
|
118
|
+
|
119
|
+
Amico.pending?(11, 1)
|
120
|
+
=> true
|
121
|
+
|
122
|
+
Amico.following?(1, 11)
|
123
|
+
=> true
|
124
|
+
|
125
|
+
Amico.following?(11, 1)
|
126
|
+
=> false
|
127
|
+
|
128
|
+
Amico.follower?(11, 1)
|
129
|
+
=> true
|
130
|
+
|
131
|
+
Amico.follower?(1, 11)
|
132
|
+
=> false
|
133
|
+
|
134
|
+
Amico.accept(11, 1)
|
135
|
+
=> [1, 1]
|
136
|
+
|
137
|
+
Amico.pending?(1, 11)
|
138
|
+
=> false
|
139
|
+
|
140
|
+
Amico.pending?(11, 1)
|
141
|
+
=> false
|
142
|
+
|
143
|
+
Amico.following?(1, 11)
|
144
|
+
=> true
|
145
|
+
|
146
|
+
Amico.following?(11, 1)
|
147
|
+
=> true
|
148
|
+
|
149
|
+
Amico.follower?(11, 1)
|
150
|
+
=> true
|
151
|
+
|
152
|
+
Amico.follower?(1, 11)
|
153
|
+
=> true
|
154
|
+
|
155
|
+
Amico.reciprocated?(1, 11)
|
156
|
+
=> true
|
157
|
+
```
|
158
|
+
|
159
|
+
Use amico with nicknames instead of IDs. NOTE: This could cause you much hardship later on if you allow nicknames to change.
|
160
|
+
|
161
|
+
```ruby
|
162
|
+
require 'amico'
|
163
|
+
|
164
|
+
Amico.configure do |configuration|
|
165
|
+
configuration.redis = Redis.new
|
166
|
+
configuration.namespace = 'amico'
|
167
|
+
configuration.following_key = 'following'
|
168
|
+
configuration.followers_key = 'followers'
|
169
|
+
configuration.blocked_key = 'blocked'
|
170
|
+
configuration.reciprocated_key = 'reciprocated'
|
171
|
+
configuration.pending_key = 'pending'
|
172
|
+
configuration.default_scope_key = 'default'
|
173
|
+
configuration.pending_follow = false
|
174
|
+
configuration.page_size = 25
|
175
|
+
end
|
176
|
+
|
177
|
+
Amico.follow('bob', 'jane')
|
178
|
+
|
179
|
+
Amico.following?('bob', 'jane')
|
180
|
+
=> true
|
181
|
+
|
182
|
+
Amico.following?('jane', 'bob')
|
183
|
+
=> false
|
184
|
+
|
185
|
+
Amico.follow('jane', 'bob')
|
186
|
+
|
187
|
+
Amico.following?('jane', 'bob')
|
188
|
+
=> true
|
189
|
+
|
190
|
+
Amico.following_count('bob')
|
191
|
+
=> 1
|
192
|
+
|
193
|
+
Amico.followers_count('bob')
|
194
|
+
=> 1
|
195
|
+
|
196
|
+
Amico.unfollow('jane', 'bob')
|
197
|
+
|
198
|
+
Amico.following_count('jane')
|
199
|
+
=> 0
|
200
|
+
|
201
|
+
Amico.following_count('bob')
|
202
|
+
=> 1
|
203
|
+
|
204
|
+
Amico.follower?('bob', 'jane')
|
205
|
+
=> false
|
206
|
+
|
207
|
+
Amico.follower?('jane', 'bob')
|
208
|
+
=> true
|
209
|
+
|
210
|
+
Amico.following('bob')
|
211
|
+
=> ["jane"]
|
212
|
+
|
213
|
+
Amico.block('bob', 'jane')
|
214
|
+
|
215
|
+
Amico.following?('jane', 'bob')
|
216
|
+
=> false
|
217
|
+
|
218
|
+
Amico.blocked?('bob', 'jane')
|
219
|
+
=> true
|
220
|
+
|
221
|
+
Amico.blocked?('jane', 'bob')
|
222
|
+
=> false
|
223
|
+
|
224
|
+
Amico.unblock('bob', 'jane')
|
225
|
+
=> true
|
226
|
+
|
227
|
+
mico.blocked?('bob', 'jane')
|
228
|
+
=> false
|
229
|
+
|
230
|
+
Amico.following?('jane', 'bob')
|
231
|
+
=> false
|
232
|
+
|
233
|
+
Amico.follow('jane', 'bob')
|
234
|
+
=> nil
|
235
|
+
|
236
|
+
Amico.follow('bob', 'jane')
|
237
|
+
=> [1, 1]
|
238
|
+
|
239
|
+
Amico.reciprocated?('bob', 'jane')
|
240
|
+
=> true
|
241
|
+
|
242
|
+
Amico.reciprocated('bob')
|
243
|
+
=> ["jane"]
|
244
|
+
```
|
245
|
+
|
246
|
+
Use amico with nicknames instead of IDs and pending follows. NOTE: This could cause you much hardship later on if you allow nicknames to change.
|
247
|
+
|
248
|
+
```ruby
|
249
|
+
require 'amico'
|
250
|
+
=> true
|
251
|
+
|
252
|
+
Amico.configure do |configuration|
|
253
|
+
configuration.redis = Redis.new
|
254
|
+
configuration.namespace = 'amico'
|
255
|
+
configuration.following_key = 'following'
|
256
|
+
configuration.followers_key = 'followers'
|
257
|
+
configuration.blocked_key = 'blocked'
|
258
|
+
configuration.reciprocated_key = 'reciprocated'
|
259
|
+
configuration.pending_key = 'pending'
|
260
|
+
configuration.default_scope_key = 'default'
|
261
|
+
configuration.pending_follow = true
|
262
|
+
configuration.page_size = 25
|
263
|
+
end
|
264
|
+
|
265
|
+
Amico.follow('bob', 'jane')
|
266
|
+
|
267
|
+
Amico.follow('jane', 'bob')
|
268
|
+
|
269
|
+
Amico.pending?('bob', 'jane')
|
270
|
+
=> true
|
271
|
+
|
272
|
+
Amico.pending?('jane', 'bob')
|
273
|
+
=> true
|
274
|
+
|
275
|
+
Amico.accept('bob', 'jane')
|
276
|
+
|
277
|
+
Amico.pending?('bob', 'jane')
|
278
|
+
=> false
|
279
|
+
|
280
|
+
Amico.pending?('jane', 'bob')
|
281
|
+
=> true
|
282
|
+
|
283
|
+
Amico.following?('bob', 'jane')
|
284
|
+
=> true
|
285
|
+
|
286
|
+
Amico.following?('jane', 'bob')
|
287
|
+
=> false
|
288
|
+
|
289
|
+
Amico.follower?('jane', 'bob')
|
290
|
+
=> true
|
291
|
+
|
292
|
+
Amico.follower?('bob', 'jane')
|
293
|
+
=> false
|
294
|
+
|
295
|
+
Amico.accept('jane', 'bob')
|
296
|
+
|
297
|
+
Amico.pending?('bob', 'jane')
|
298
|
+
=> false
|
299
|
+
|
300
|
+
Amico.pending?('jane', 'bob')
|
301
|
+
=> false
|
302
|
+
|
303
|
+
Amico.following?('bob', 'jane')
|
304
|
+
=> true
|
305
|
+
|
306
|
+
Amico.following?('jane', 'bob')
|
307
|
+
=> true
|
308
|
+
|
309
|
+
Amico.follower?('jane', 'bob')
|
310
|
+
=> true
|
311
|
+
|
312
|
+
Amico.follower?('bob', 'jane')
|
313
|
+
=> true
|
314
|
+
|
315
|
+
Amico.reciprocated?('bob', 'jane')
|
316
|
+
=> true
|
317
|
+
```
|
318
|
+
|
319
|
+
All of the calls support a `scope` parameter to allow you to scope the calls to express relationships for different types of things. For example:
|
320
|
+
|
321
|
+
```ruby
|
322
|
+
require 'amico'
|
323
|
+
|
324
|
+
Amico.configure do |configuration|
|
325
|
+
configuration.redis = Redis.new
|
326
|
+
configuration.namespace = 'amico'
|
327
|
+
configuration.following_key = 'following'
|
328
|
+
configuration.followers_key = 'followers'
|
329
|
+
configuration.blocked_key = 'blocked'
|
330
|
+
configuration.reciprocated_key = 'reciprocated'
|
331
|
+
configuration.pending_key = 'pending'
|
332
|
+
configuration.default_scope_key = 'user'
|
333
|
+
configuration.pending_follow = false
|
334
|
+
configuration.page_size = 25
|
335
|
+
end
|
336
|
+
|
337
|
+
Amico.follow(1, 11)
|
338
|
+
|
339
|
+
Amico.following?(1, 11)
|
340
|
+
=> true
|
341
|
+
|
342
|
+
Amico.following?(1, 11, 'user')
|
343
|
+
=> true
|
344
|
+
|
345
|
+
Amico.following(1)
|
346
|
+
=> ["11"]
|
347
|
+
|
348
|
+
Amico.following(1, {:page_size => Amico.page_size, :page => 1}, 'user')
|
349
|
+
=> ["11"]
|
350
|
+
|
351
|
+
Amico.following?(1, 11, 'project')
|
352
|
+
=> false
|
353
|
+
|
354
|
+
Amico.follow(1, 11, 'project')
|
355
|
+
|
356
|
+
Amico.following?(1, 11, 'project')
|
357
|
+
=> true
|
358
|
+
|
359
|
+
Amico.following(1, {:page_size => Amico.page_size, :page => 1}, 'project')
|
360
|
+
=> ["11"]
|
361
|
+
```
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# 2.0.0
|
2
|
+
|
3
|
+
* Added `Amico.default_scope_key` and `scope` parameter to all of the methods to allow you to scope the calls to express relationships for different types of things
|
4
|
+
|
5
|
+
# 1.2.0
|
6
|
+
|
7
|
+
* Added pending to relationships
|
8
|
+
|
9
|
+
# 1.1.0
|
10
|
+
|
11
|
+
* Added blocking to relationships
|
12
|
+
* Added reciprocated to relationships
|
13
|
+
|
14
|
+
# 1.0.0 (2012-01-11)
|
15
|
+
|
16
|
+
* Initial release
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 David Czarnecki
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,185 @@
|
|
1
|
+
# acts_as_amico
|
2
|
+
|
3
|
+
ActiveModel injectable relationships (e.g. friendships) backed by Redis.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
`gem install acts_as_amico`
|
8
|
+
|
9
|
+
or in your `Gemfile`
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'acts_as_amico'
|
13
|
+
```
|
14
|
+
|
15
|
+
Make sure your redis server is running! Redis configuration is outside the scope of this README, but
|
16
|
+
check out the Redis documentation, http://redis.io/documentation.
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
Configure amico:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
Amico.configure do |configuration|
|
24
|
+
configuration.redis = Redis.new
|
25
|
+
configuration.namespace = 'amico'
|
26
|
+
configuration.following_key = 'following'
|
27
|
+
configuration.followers_key = 'followers'
|
28
|
+
configuration.blocked_key = 'blocked'
|
29
|
+
configuration.reciprocated_key = 'reciprocated'
|
30
|
+
configuration.pending_key = 'pending'
|
31
|
+
configuration.default_scope_key = 'default'
|
32
|
+
configuration.pending_follow = false
|
33
|
+
configuration.page_size = 25
|
34
|
+
end
|
35
|
+
```
|
36
|
+
|
37
|
+
### Amico module loadable methods:
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
require 'amico'
|
41
|
+
=> true
|
42
|
+
|
43
|
+
Amico.configure do |configuration|
|
44
|
+
configuration.redis = Redis.new
|
45
|
+
configuration.namespace = 'amico'
|
46
|
+
configuration.following_key = 'following'
|
47
|
+
configuration.followers_key = 'followers'
|
48
|
+
configuration.blocked_key = 'blocked'
|
49
|
+
configuration.reciprocated_key = 'reciprocated'
|
50
|
+
configuration.pending_key = 'pending'
|
51
|
+
configuration.default_scope_key = 'default'
|
52
|
+
configuration.pending_follow = false
|
53
|
+
configuration.page_size = 25
|
54
|
+
end
|
55
|
+
|
56
|
+
class User < ActiveRecord::Base
|
57
|
+
acts_as_amico
|
58
|
+
end
|
59
|
+
|
60
|
+
usera = User.create
|
61
|
+
userb = user.create
|
62
|
+
|
63
|
+
usera.follow! userb
|
64
|
+
=> nil
|
65
|
+
|
66
|
+
usera.following? userb
|
67
|
+
=> true
|
68
|
+
|
69
|
+
userb.following? usera
|
70
|
+
=> false
|
71
|
+
|
72
|
+
userb.follow! usera
|
73
|
+
=> [1, 1]
|
74
|
+
|
75
|
+
userb.following? usera
|
76
|
+
=> true
|
77
|
+
|
78
|
+
usera.following_count
|
79
|
+
=> 1
|
80
|
+
|
81
|
+
usera.followers_count
|
82
|
+
=> 1
|
83
|
+
|
84
|
+
userb.unfollow! usera
|
85
|
+
=> [1, 1, 1, 1, 0]
|
86
|
+
|
87
|
+
userb.following_count
|
88
|
+
=> 0
|
89
|
+
|
90
|
+
usera.following_count
|
91
|
+
=> 1
|
92
|
+
|
93
|
+
usera.follower? userb
|
94
|
+
=> false
|
95
|
+
|
96
|
+
puts userb.id
|
97
|
+
=> 11
|
98
|
+
|
99
|
+
usera.following
|
100
|
+
=> ["11"]
|
101
|
+
|
102
|
+
usera.block! userb
|
103
|
+
=> [1, 0, 1, 0, 0, 0, 0, 1]
|
104
|
+
|
105
|
+
userb.following? usera
|
106
|
+
=> false
|
107
|
+
|
108
|
+
usera.blocked? userb
|
109
|
+
=> true
|
110
|
+
|
111
|
+
usera.unblock! userb
|
112
|
+
=> true
|
113
|
+
|
114
|
+
usera.blocked? userb
|
115
|
+
=> false
|
116
|
+
|
117
|
+
userb.follow! usera
|
118
|
+
=> nil
|
119
|
+
|
120
|
+
usera.follow! userb
|
121
|
+
=> [1, 1]
|
122
|
+
|
123
|
+
usera.reciprocated? userb
|
124
|
+
=> true
|
125
|
+
|
126
|
+
puts userb.id
|
127
|
+
=> 11
|
128
|
+
|
129
|
+
usera.reciprocated
|
130
|
+
=> ["11"]
|
131
|
+
```
|
132
|
+
|
133
|
+
You can also use non-id keys:
|
134
|
+
|
135
|
+
```ruby
|
136
|
+
class Admin < ActiveRecord::Base
|
137
|
+
acts_as_amico :amico_key => "name"
|
138
|
+
validates_uniqueness_of :name # -> do this or be sorry :)
|
139
|
+
end
|
140
|
+
|
141
|
+
usera = User.create
|
142
|
+
|
143
|
+
puts usera.id
|
144
|
+
=> 18
|
145
|
+
|
146
|
+
admin = Admin.create :name => "frank"
|
147
|
+
|
148
|
+
usera.follow! admin
|
149
|
+
=> nil
|
150
|
+
|
151
|
+
admin.follow! usera
|
152
|
+
=> [1, 1]
|
153
|
+
|
154
|
+
admin.followers
|
155
|
+
=> ["18"]
|
156
|
+
|
157
|
+
usera.followers
|
158
|
+
=> ["frank"]
|
159
|
+
```
|
160
|
+
|
161
|
+
## Documentation
|
162
|
+
|
163
|
+
Acts_as_amico is feature complete with the amico gem. [The Amico API usage page](https://github.com/mettadore/amico/blob/master/API.md)
|
164
|
+
shows a more complete suite of methods. The source for the [Amico relationships module](https://github.com/agoragames/amico/blob/master/lib/amico/relationships.rb)
|
165
|
+
is well-documented. There are some simple examples in the method documentation. You can also refer to the
|
166
|
+
[Amico online documentation](http://rubydoc.info/github/agoragames/amico/master/frames).
|
167
|
+
|
168
|
+
## Future Plans
|
169
|
+
|
170
|
+
Clean up the ActiveResource integration
|
171
|
+
|
172
|
+
## Contributing to acts_as_amico
|
173
|
+
|
174
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
175
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
176
|
+
* Fork the project
|
177
|
+
* Start a feature/bugfix branch
|
178
|
+
* Commit and push until you are happy with your contribution
|
179
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
180
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
181
|
+
|
182
|
+
## Copyright
|
183
|
+
|
184
|
+
Copyright (c) John Metta. See LICENSE.txt for further details.
|
185
|
+
|