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.
- checksums.yaml +4 -4
- data/README.md +8 -45
- data/lib/acts_as_favoritor.rb +3 -3
- data/lib/acts_as_favoritor/favoritable.rb +53 -334
- data/lib/acts_as_favoritor/favoritor.rb +111 -484
- data/lib/acts_as_favoritor/favoritor_lib.rb +11 -26
- data/lib/acts_as_favoritor/version.rb +1 -1
- data/lib/generators/templates/model.rb +1 -1
- metadata +13 -13
@@ -8,41 +8,26 @@ module ActsAsFavoritor
|
|
8
8
|
|
9
9
|
# Retrieves the parent class name if using STI.
|
10
10
|
def parent_class_name(obj)
|
11
|
-
unless
|
11
|
+
unless DEFAULT_PARENTS.include? obj.class.superclass
|
12
12
|
return obj.class.base_class.name
|
13
13
|
end
|
14
14
|
|
15
15
|
obj.class.name
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
18
|
+
def build_result_for_scopes(scopes)
|
19
|
+
return if scopes.empty?
|
20
|
+
|
21
|
+
scopes = sanitized_scopes(scopes)
|
22
|
+
result = scopes.map { |scope| [scope, yield(scope)] }.to_h
|
23
|
+
|
24
|
+
return result[scopes.first] if scopes.size == 1
|
26
25
|
|
27
|
-
|
28
|
-
DEFAULT_PARENTS
|
26
|
+
result
|
29
27
|
end
|
30
28
|
|
31
|
-
def
|
32
|
-
|
33
|
-
if options[:scope].size > 1
|
34
|
-
options[:multiple_scopes] = true
|
35
|
-
else
|
36
|
-
options[:multiple_scopes] = false
|
37
|
-
options[:scope] = options[:scope][0]
|
38
|
-
end
|
39
|
-
if options.key? :parameter
|
40
|
-
parameter = options[:parameter]
|
41
|
-
options.delete :parameter
|
42
|
-
send(method, parameter, options)
|
43
|
-
else
|
44
|
-
send(method, options)
|
45
|
-
end
|
29
|
+
def sanitized_scopes(scopes)
|
30
|
+
scopes.map(&:to_sym)
|
46
31
|
end
|
47
32
|
end
|
48
33
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_favoritor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Hübotter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '5.
|
19
|
+
version: '5.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '5.
|
26
|
+
version: '5.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: factory_bot
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -42,18 +42,18 @@ dependencies:
|
|
42
42
|
name: rails
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rspec-rails
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: rubocop
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: rubocop-rspec
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|