acts_as_favoritor 2.1.2 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,547 +8,174 @@ module ActsAsFavoritor
8
8
 
9
9
  module ClassMethods
10
10
  def acts_as_favoritor
11
+ if ActsAsFavoritor.configuration&.cache
12
+ serialize :favoritor_score, Hash
13
+ serialize :favoritor_total, Hash
14
+ end
15
+
11
16
  has_many :favorites, as: :favoritor, dependent: :destroy
17
+
12
18
  include ActsAsFavoritor::Favoritor::InstanceMethods
13
19
  include ActsAsFavoritor::FavoritorLib
14
-
15
- return unless ActsAsFavoritor.configuration&.cache
16
-
17
- serialize :favoritor_score, Hash
18
- serialize :favoritor_total, Hash
19
20
  end
20
21
  end
21
22
 
23
+ # rubocop:disable Metrics/ModuleLength
22
24
  module InstanceMethods
23
- # Returns true if this instance has favorited the object passed as an
24
- # argument.
25
- def favorited?(favoritable, options = {})
26
- if options.key?(:multiple_scopes) == false
27
- options[:parameter] = favoritable
28
- validate_scopes(__method__, options)
29
- elsif options[:multiple_scopes]
30
- results = {}
31
- options[:scope].each do |scope|
32
- results[scope] = Favorite.unblocked.send(scope.to_s + '_list')
33
- .for_favoritor(self)
34
- .for_favoritable(favoritable).count
35
- .positive?
36
- end
37
- results
25
+ # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
26
+ def method_missing(method, *args)
27
+ if method.to_s[/favorited_(.+)/]
28
+ favorited_by_type($1.singularize.classify)
29
+ elsif ActsAsFavoritor.configuration.cache &&
30
+ method.to_s[/favoritor_(.+)_score/]
31
+ favoritor_score[$1.singularize.classify]
32
+ elsif ActsAsFavoritor.configuration.cache &&
33
+ method.to_s[/favoritor_(.+)_total/]
34
+ favoritor_total[$1.singularize.classify]
38
35
  else
39
- Favorite.unblocked.send(options[:scope].to_s + '_list')
40
- .for_favoritor(self).for_favoritable(favoritable)
41
- .count.positive?
36
+ super
42
37
  end
43
38
  end
39
+ # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
44
40
 
45
- # Returns true if this instance has blocked the object passed as an
46
- # argument.
47
- def blocked?(favoritable, options = {})
48
- if options.key?(:multiple_scopes) == false
49
- options[:parameter] = favoritable
50
- validate_scopes(__method__, options)
51
- elsif options[:multiple_scopes]
52
- results = {}
53
- options[:scope].each do |scope|
54
- results[scope] = Favorite.blocked.send(scope + '_list')
55
- .for_favoritor(self)
56
- .for_favoritable(favoritable).count
57
- .positive?
58
- end
59
- results
60
- else
61
- Favorite.blocked.send(options[:scope] + '_list').for_favoritor(self)
62
- .for_favoritable(favoritable).count.positive?
63
- end
41
+ def respond_to_missing?(method, include_private = false)
42
+ super || method.to_s[/favorited_(.+)/] ||
43
+ method.to_s[/favoritor_(.+)_score/] ||
44
+ method.to_s[/favoritor_(.+)_total/]
64
45
  end
65
46
 
66
- # Returns true if this instance has favorited the object passed as an
67
- # argument. Returns nil if this instance has not favorited the object
68
- # passed as an argument. Returns false if this instance has blocked the
69
- # object passed as an argument.
70
- def favorited_type(favoritable, options = {})
71
- if options.key?(:multiple_scopes) == false
72
- options[:parameter] = favoritable
73
- validate_scopes(__method__, options)
74
- elsif options[:multiple_scopes]
75
- results = {}
76
- options[:scope].each do |scope|
77
- if Favorite.unblocked.send(scope + '_list').for_favoritor(self)
78
- .for_favoritable(favoritable).count.positive?
79
- results[scope] = true
80
- elsif Favorite.blocked.send(scope + '_list').for_favoritor(self)
81
- .for_favoritable(favoritable).count.positive?
82
- results[scope] = false
83
- else
84
- results[scope] = nil
85
- end
86
- end
87
- results
88
- elsif Favorite.unblocked.send(options[:scope] + '_list')
89
- .for_favoritor(self).for_favoritable(favoritable).count
90
- .positive?
91
- true
92
- elsif Favorite.blocked.send(options[:scope] + '_list')
93
- .for_favoritor(self).for_favoritable(favoritable).count
94
- .positive?
95
- false
96
- end
97
- end
47
+ def favorite(favoritable,
48
+ scopes: [ActsAsFavoritor.configuration.default_scope])
49
+ build_result_for_scopes scopes do |scope|
50
+ return if self == favoritable
51
+ return if scope == :all
98
52
 
99
- # Returns the number of objects this instance has favorited.
100
- def favorites_count(options = {})
101
- if options.key?(:multiple_scopes) == false
102
- validate_scopes(__method__, options)
103
- elsif options[:multiple_scopes]
104
- results = {}
105
- options[:scope].each do |scope|
106
- results[scope] = Favorite.unblocked.send(scope + '_list')
107
- .for_favoritor(self).count
108
- end
109
- results
110
- else
111
- Favorite.unblocked.send(options[:scope] + '_list')
112
- .for_favoritor(self).count
53
+ inc_cache if ActsAsFavoritor.configuration.cache
54
+
55
+ favorites.where(
56
+ favoritable_id: favoritable.id,
57
+ favoritable_type: parent_class_name(favoritable),
58
+ scope: scope
59
+ ).first_or_create!
113
60
  end
114
61
  end
115
62
 
116
- # Creates a new favorite record for this instance to favorite the passed
117
- # object. Does not allow duplicate records to be created.
118
- def favorite(favoritable, options = {})
119
- if options.key?(:multiple_scopes) == false
120
- options[:parameter] = favoritable
121
- validate_scopes(__method__, options)
122
- elsif options[:multiple_scopes]
123
- results = {}
124
- options[:scope].each do |scope|
125
- if ActsAsFavoritor.configuration.cache
126
- favoritor_score[scope] = (favoritor_score[scope] || 0) + 1
127
- favoritor_total[scope] = (favoritor_total[scope] || 0) + 1
128
- save!
129
- favoritable.favoritable_score[scope] =
130
- (favoritable.favoritable_score[scope] || 0) + 1
131
- favoritable.favoritable_total[scope] =
132
- (favoritable.favoritable_total[scope] || 0) + 1
133
- favoritable.save!
134
- end
135
- next unless self != favoritable && scope != 'all'
63
+ def remove_favorite(favoritable,
64
+ scopes: [ActsAsFavoritor.configuration.default_scope])
65
+ build_result_for_scopes scopes do |scope|
66
+ dec_cache if ActsAsFavoritor.configuration.cache
136
67
 
137
- params = {
138
- favoritable_id: favoritable.id,
139
- favoritable_type: parent_class_name(favoritable),
140
- scope: scope
141
- }
142
- results[scope] = favorites.where(params).first_or_create!
143
- end
144
- results
145
- else
146
- if ActsAsFavoritor.configuration.cache
147
- favoritor_score[options[:scope]] =
148
- (favoritor_score[options[:scope]] || 0) + 1
149
- favoritor_total[options[:scope]] =
150
- (favoritor_total[options[:scope]] || 0) + 1
151
- save!
152
- favoritable.favoritable_score[options[:scope]] =
153
- (favoritable.favoritable_score[options[:scope]] || 0) + 1
154
- favoritable.favoritable_total[options[:scope]] =
155
- (favoritable.favoritable_total[options[:scope]] || 0) + 1
156
- favoritable.save!
157
- end
158
- if self != favoritable && options[:scope] != 'all'
159
- params = {
160
- favoritable_id: favoritable.id,
161
- favoritable_type: parent_class_name(favoritable),
162
- scope: options[:scope]
163
- }
164
- favorites.where(params).first_or_create!
165
- end
68
+ get_favorite(favoritable, scope)&.destroy
166
69
  end
167
70
  end
168
71
 
169
- # Deletes the favorite record if it exists.
170
- def remove_favorite(favoritable, options = {})
171
- if options.key?(:multiple_scopes) == false
172
- options[:parameter] = favoritable
173
- validate_scopes(__method__, options)
174
- elsif options[:multiple_scopes]
175
- results = {}
176
- options[:scope].each do |scope|
177
- if ActsAsFavoritor.configuration.cache
178
- favoritor_score[scope] = favoritor_score[scope] - 1
179
- unless favoritor_score[scope].positive?
180
- favoritor_score.delete(scope)
181
- end
182
- save!
183
- favoritable.favoritable_score[scope] =
184
- favoritable.favoritable_score[scope] - 1
185
- unless favoritable.favoritable_score[scope].positive?
186
- favoritable.favoritable_score.delete(scope)
187
- end
188
- favoritable.save!
189
- end
190
- favorite = get_favorite(
191
- favoritable, scope: scope, multiple_scopes: false
192
- )
193
- results[scope] = favorite.destroy if favorite
194
- end
195
- results
196
- else
197
- if ActsAsFavoritor.configuration.cache
198
- favoritor_score[options[:scope]] =
199
- favoritor_score[options[:scope]] - 1
200
- unless favoritor_score[options[:scope]].positive?
201
- favoritor_score.delete(options[:scope])
202
- end
203
- save!
204
- favoritable.favoritable_score[options[:scope]] =
205
- favoritable.favoritable_score[options[:scope]] - 1
206
- unless favoritable.favoritable_score[options[:scope]].positive?
207
- favoritable.favoritable_score.delete(options[:scope])
208
- end
209
- favoritable.save!
210
- end
211
- favorite = get_favorite(
212
- favoritable, scope: options[:scope], multiple_scopes: false
213
- )
214
- favorite&.destroy
72
+ def favorited?(favoritable,
73
+ scopes: [ActsAsFavoritor.configuration.default_scope])
74
+ build_result_for_scopes scopes do |scope|
75
+ Favorite.unblocked.send("#{scope}_list").for_favoritor(self)
76
+ .for_favoritable(favoritable).size.positive?
215
77
  end
216
78
  end
217
79
 
218
- # returns the favorite records to the current instance
219
- def favorites_scoped(options = {})
220
- if options.key?(:multiple_scopes) == false
221
- validate_scopes(__method__, options)
222
- elsif options[:multiple_scopes]
223
- results = {}
224
- options[:scope].each do |scope|
225
- results[scope] = favorites.unblocked.send(scope + '_list')
226
- .includes(:favoritable)
227
- end
228
- results
229
- else
230
- favorites.unblocked.send(options[:scope] + '_list')
231
- .includes(:favoritable)
80
+ def all_favorites(scopes: [ActsAsFavoritor.configuration.default_scope])
81
+ build_result_for_scopes scopes do |scope|
82
+ favorites.unblocked.send("#{scope}_list")
232
83
  end
233
84
  end
234
85
 
235
- # Returns the favorite records related to this instance by type.
236
- def favorites_by_type(favoritable_type, options = {})
237
- if options.key?(:multiple_scopes) == false
238
- options[:parameter] = favoritable_type
239
- validate_scopes(__method__, options)
240
- elsif options[:multiple_scopes]
241
- results = {}
242
- options[:scope].each do |scope|
243
- favorites_scope = favorites_scoped(
244
- scope: scope, multiple_scopes: false
245
- ).for_favoritable_type(favoritable_type)
246
- results[scope] = apply_options_to_scope(
247
- favorites_scope, options
248
- )
249
- end
250
- results
251
- else
252
- favorites_scope = favorites_scoped(
253
- scope: options[:scope], multiple_scopes: false
254
- ).for_favoritable_type(favoritable_type)
255
- apply_options_to_scope(
256
- favorites_scope, options
257
- )
86
+ def all_favorited(scopes: [ActsAsFavoritor.configuration.default_scope])
87
+ build_result_for_scopes scopes do |scope|
88
+ favorites.unblocked.send("#{scope}_list").includes(:favoritable)
89
+ .map(&:favoritable)
258
90
  end
259
91
  end
260
92
 
261
- # Returns the favorite records related to this instance with the
262
- # favoritable included.
263
- def all_favorites(options = {})
264
- if options.key?(:multiple_scopes) == false
265
- validate_scopes(__method__, options)
266
- elsif options[:multiple_scopes]
267
- results = {}
268
- options[:scope].each do |scope|
269
- favorites_scope = favorites_scoped(
270
- scope: scope, multiple_scopes: false
271
- )
272
- results[scope] = apply_options_to_scope(
273
- favorites_scope, options
274
- )
275
- end
276
- results
277
- else
278
- favorites_scope = favorites_scoped(
279
- scope: options[:scope], multiple_scopes: false
280
- )
281
- apply_options_to_scope(
282
- favorites_scope, options
283
- )
93
+ def favorites_by_type(favoritable_type,
94
+ scopes: [ActsAsFavoritor.configuration
95
+ .default_scope])
96
+ build_result_for_scopes scopes do |scope|
97
+ favorites.unblocked.send("#{scope}_list").includes(:favoritable)
98
+ .for_favoritable_type(favoritable_type)
284
99
  end
285
100
  end
286
101
 
287
- # Returns the actual records which this instance has favorited.
288
- def all_favorited(options = {})
289
- if options.key?(:multiple_scopes) == false
290
- validate_scopes(__method__, options)
291
- elsif options[:multiple_scopes]
292
- results = {}
293
- options[:scope].each do |scope|
294
- results[scope] = all_favorites(options).collect(&:favoritable)
295
- end
296
- results
297
- else
298
- all_favorites(options).collect(&:favoritable)
102
+ def favorited_by_type(favoritable_type,
103
+ scopes: [ActsAsFavoritor.configuration
104
+ .default_scope])
105
+ build_result_for_scopes scopes do |scope|
106
+ favorites.unblocked.send("#{scope}_list")
107
+ .for_favoritable_type(favoritable_type).map(&:favoritable)
299
108
  end
300
109
  end
301
110
 
302
- # Returns the actual records of a particular type which this record has
303
- # favorited.
304
- def favorited_by_type(favoritable_type, options = {})
305
- if options.key?(:multiple_scopes) == false
306
- options[:parameter] = favoritable_type
307
- validate_scopes(__method__, options)
308
- elsif options[:multiple_scopes]
309
- results = {}
310
- options[:scope].each do |scope|
311
- favoritables = favoritable_type.constantize.joins(:favorited)
312
- favoritables = favoritables.where(
313
- 'favorites.blocked': false,
314
- 'favorites.favoritor_id': id,
315
- 'favorites.favoritor_type': parent_class_name(self),
316
- 'favorites.favoritable_type': favoritable_type,
317
- 'favorites.scope': scope
318
- )
319
- if options.key?(:limit)
320
- favoritables = favoritables.limit options[:limit]
321
- end
322
- if options.key?(:includes)
323
- favoritables = favoritables.includes options[:includes]
324
- end
325
- results[scope] = favoritables
326
- end
327
- results
328
- else
329
- favoritables = favoritable_type.constantize.joins(:favorited)
330
- favoritables = favoritables.where(
331
- 'favorites.blocked': false,
332
- 'favorites.favoritor_id': id,
333
- 'favorites.favoritor_type': parent_class_name(self),
334
- 'favorites.favoritable_type': favoritable_type,
335
- 'favorites.scope': options[:scope]
111
+ def block(favoritable,
112
+ scopes: [ActsAsFavoritor.configuration.default_scope])
113
+ build_result_for_scopes scopes do |scope|
114
+ get_favorite(favoritable, scope).block! || Favorite.create(
115
+ favoritable: favoritable,
116
+ favoritor: self,
117
+ blocked: true,
118
+ scope: scope
336
119
  )
337
- if options.key? :limit
338
- favoritables = favoritables.limit options[:limit]
339
- end
340
- if options.key? :includes
341
- favoritables = favoritables.includes options[:includes]
342
- end
343
- favoritables
344
120
  end
345
121
  end
346
122
 
347
- def favorited_by_type_count(favoritable_type, options = {})
348
- if options.key?(:multiple_scopes) == false
349
- options[:parameter] = favoritable_type
350
- validate_scopes(__method__, options)
351
- elsif options[:multiple_scopes]
352
- results = {}
353
- options[:scope].each do |scope|
354
- results[scope] = favorites.unblocked
355
- .send(scope + '_list')
356
- .for_favoritable_type(favoritable_type)
357
- .count
358
- end
359
- results
360
- else
361
- favorites.unblocked.send(options[:scope] + '_list')
362
- .for_favoritable_type(favoritable_type).count
123
+ def unblock(favoritable,
124
+ scopes: [ActsAsFavoritor.configuration.default_scope])
125
+ build_result_for_scopes scopes do |scope|
126
+ get_favorite(favoritable, scope)&.update(blocked: false)
363
127
  end
364
128
  end
365
129
 
366
- # Allows magic names on favorited_by_type
367
- # e.g. favorited_users == favorited_by_type 'User'
368
- # Allows magic names on favorited_by_type_count
369
- # e.g. favorited_users_count == favorited_by_type_count 'User'
370
- def method_missing(method, *args)
371
- if method.to_s[/favorited_(.+)_count/]
372
- favorited_by_type_count $1.singularize.classify
373
- elsif method.to_s[/favorited_(.+)/]
374
- favorited_by_type $1.singularize.classify
375
- elsif ActsAsFavoritor.configuration.cache &&
376
- method.to_s[/favoritor_(.+)_score/]
377
- favoritor_score[$1.singularize.classify]
378
- elsif ActsAsFavoritor.configuration.cache &&
379
- method.to_s[/favoritor_(.+)_total/]
380
- favoritor_total[$1.singularize.classify]
381
- else
382
- super
130
+ def blocked?(favoritable,
131
+ scopes: [ActsAsFavoritor.configuration.default_scope])
132
+ build_result_for_scopes scopes do |scope|
133
+ Favorite.blocked.send("#{scope}_list").for_favoritor(self)
134
+ .for_favoritable(favoritable).size.positive?
383
135
  end
384
136
  end
385
137
 
386
- def respond_to_missing?(method, include_private = false)
387
- super || method.to_s[/favorited_(.+)_count/] ||
388
- method.to_s[/favorited_(.+)/]
389
- end
390
-
391
- # Returns a favorite record for the current instance and favoritable
392
- # object.
393
- def get_favorite(favoritable, options = {})
394
- if options.key?(:multiple_scopes) == false
395
- options[:parameter] = favoritable
396
- validate_scopes(__method__, options)
397
- elsif options[:multiple_scopes]
398
- results = {}
399
- options[:scope].each do |scope|
400
- results[scope] = favorites.unblocked.send(scope.to_s + '_list')
401
- .for_favoritable(favoritable).first
402
- end
403
- results
404
- else
405
- favorites.unblocked.send(options[:scope].to_s + '_list')
406
- .for_favoritable(favoritable).first
138
+ def blocks(scopes: [ActsAsFavoritor.configuration.default_scope])
139
+ build_result_for_scopes scopes do |scope|
140
+ favorites.includes(:favoritable).blocked.send("#{scope}_list")
141
+ .map(&:favoritable)
407
142
  end
408
143
  end
409
144
 
410
- def blocks(options = {})
411
- if options.key?(:multiple_scopes) == false
412
- validate_scopes(__method__, options)
413
- elsif options[:multiple_scopes]
414
- results = {}
415
- options[:scope].each do |scope|
416
- blocked_favoritors_scope = favoritables_scoped(
417
- scope: scope, multiple_scopes: false
418
- ).blocked
419
- blocked_favoritors_scope = apply_options_to_scope(
420
- blocked_favoritors_scope, options
421
- )
422
- results[scope] = blocked_favoritors_scope.to_a
423
- .collect(&:favoritable)
424
- end
425
- results
426
- else
427
- blocked_favoritors_scope = favoritors_scoped(
428
- scope: options[:scope], multiple_scopes: false
429
- ).blocked
430
- blocked_favoritors_scope = apply_options_to_scope(
431
- blocked_favoritors_scope, options
432
- )
433
- blocked_favoritors_scope.to_a.collect(&:favoritable)
434
- end
435
- end
145
+ private
436
146
 
437
- def block(favoritable, options = {})
438
- if options.key?(:multiple_scopes) == false
439
- options[:parameter] = favoritable
440
- validate_scopes(__method__, options)
441
- elsif options[:multiple_scopes]
442
- results = {}
443
- options[:scope].each do |scope|
444
- favorite = get_favorite(
445
- favoritable, scope: scope, multiple_scopes: false
446
- )
447
- if favorite
448
- results[scope] = block_existing_favorite(
449
- favoritable, scope: scope, multiple_scopes: false
450
- )
451
- else
452
- results[scope] = block_future_favorite(
453
- favoritable, scope: scope, multiple_scopes: false
454
- )
455
- end
456
- end
457
- results
458
- else
459
- favorite = get_favorite(
460
- favoritable, scope: options[:scope], multiple_scopes: false
461
- )
462
- if favorite
463
- block_existing_favorite(
464
- favoritable, scope: options[:scope], multiple_scopes: false
465
- )
466
- else
467
- block_future_favorite(
468
- favoritable, scope: options[:scope], multiple_scopes: false
469
- )
470
- end
471
- end
147
+ def get_favorite(favoritable, scope)
148
+ favorites.unblocked.send("#{scope}_list").for_favoritable(favoritable)
149
+ .first
472
150
  end
473
151
 
474
- def unblock(favoritable, options = {})
475
- if options.key?(:multiple_scopes) == false
476
- options[:parameter] = favoritable
477
- validate_scopes(__method__, options)
478
- elsif options[:multiple_scopes]
479
- results = {}
480
- options[:scope].each do |scope|
481
- results[scope] = get_favorite(
482
- favoritable, scope: scope, multiple_scopes: false
483
- )&.update_attribute :blocked, false
484
- end
485
- results
486
- else
487
- get_favorite(
488
- favoritable, scope: options[:scope], multiple_scopes: false
489
- )&.update_attribute :blocked, false
490
- end
491
- end
152
+ # rubocop:disable Metrics/AbcSize
153
+ def inc_cache
154
+ favoritor_score[scope] = (favoritor_score[scope] || 0) + 1
155
+ favoritor_total[scope] = (favoritor_total[scope] || 0) + 1
156
+ save!
492
157
 
493
- def blocked_favoritables_count(options = {})
494
- if options.key?(:multiple_scopes) == false
495
- validate_scopes(__method__, options)
496
- elsif options[:multiple_scopes]
497
- results = {}
498
- options[:scope].each do |scope|
499
- results[scope] = favorites.blocked.send(scope + '_list').count
500
- end
501
- results
502
- else
503
- favorites.blocked.send(options[:scope] + '_list').count
504
- end
158
+ favoritable.favoritable_score[scope] =
159
+ (favoritable.favoritable_score[scope] || 0) + 1
160
+ favoritable.favoritable_total[scope] =
161
+ (favoritable.favoritable_total[scope] || 0) + 1
162
+ favoritable.save!
505
163
  end
506
164
 
507
- private
508
-
509
- def block_future_favorite(favoritable, options = {})
510
- if options.key?(:multiple_scopes) == false
511
- options[:parameter] = favoritable
512
- validate_scopes(__method__, options)
513
- elsif options[:multiple_scopes]
514
- results = {}
515
- options[:scope].each do |scope|
516
- results[scope] = Favorite.create(
517
- favoritable: favoritable,
518
- favoritor: self,
519
- blocked: true,
520
- scope: scope
521
- )
522
- end
523
- results
524
- else
525
- Favorite.create(
526
- favoritable: favoritable,
527
- favoritor: self,
528
- blocked: true,
529
- scope: options[:scope]
530
- )
531
- end
532
- end
165
+ def dec_cache
166
+ favoritor_score[scope] = (favoritor_score[scope] || 0) - 1
167
+ favoritor_score.delete(scope) unless favoritor_score[scope].positive?
168
+ save!
533
169
 
534
- def block_existing_favorite(favoritable, options = {})
535
- if options.key?(:multiple_scopes) == false
536
- options[:parameter] = favoritable
537
- validate_scopes(__method__, options)
538
- elsif options[:multiple_scopes]
539
- results = {}
540
- options[:scope].each do |scope|
541
- results[scope] = get_favorite(
542
- favoritable, scope: scope, multiple_scopes: false
543
- ).block!
544
- end
545
- results
546
- else
547
- get_favorite(
548
- favoritable, scope: options[:scope], multiple_scopes: false
549
- ).block!
550
- end
170
+ favoritable.favoritable_score[scope] =
171
+ (favoritable.favoritable_score[scope] || 0) - 1
172
+ # rubocop:disable Metrics/LineLength
173
+ favoritable.favoritable_score.delete(scope) unless favoritable.favoritable_score[scope].positive?
174
+ # rubocop:enable Metrics/LineLength
175
+ favoritable.save!
551
176
  end
177
+ # rubocop:enable Metrics/AbcSize
552
178
  end
179
+ # rubocop:enable Metrics/ModuleLength
553
180
  end
554
181
  end