active_flags 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_flags.rb +3 -6
- data/lib/active_flags/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5e9e8a7d28e9b72164485acc16beb6e5e41fe28bb47fb80d98d2a9337d17b99
|
4
|
+
data.tar.gz: 53926a68eff6f2ecf294fd076ec0616c159f57fe4137d785999a5a831d165275
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32cae899f8cfb2f64f2ba25b868c981b2e36bf1bf947303a7bc27375b5efbf6cff22c11c2ec37cd73d43694922ad6bbb392c85d971c8dd89f4360ee84c24df8f
|
7
|
+
data.tar.gz: 554eeb7c3c1973e1b56e31ee6d362e4dcb837a5b97b4fcbc59e34589ec1295966a208fcd4d7b302d3da22cee4208874b5a45b8bbc56c7d2404af677d8de0b984
|
data/lib/active_flags.rb
CHANGED
@@ -33,15 +33,12 @@ module ActiveFlags
|
|
33
33
|
|
34
34
|
def method_missing(method_name, *args, &block)
|
35
35
|
return super unless method_name.to_s.include?(prefix = ACTIVE_FLAGS_PREFIX)
|
36
|
-
|
37
36
|
different_from = method_name.to_s.starts_with?('not')
|
38
37
|
flag = method_name.to_s.gsub(different_from ? "not_#{prefix}" : prefix, '')
|
39
|
-
|
38
|
+
result = joins(:flags_as_collection)
|
39
|
+
.where(active_flags_flags: { key: flag, value: stringify(args[0]) })
|
40
40
|
|
41
|
-
|
42
|
-
.where(active_flags_flags: { key: flag })
|
43
|
-
.send(different_from ? 'where' : 'all')
|
44
|
-
.send(different_from ? 'not' : 'where', condition)
|
41
|
+
different_from ? where.not(id: result.pluck(:id)) : result
|
45
42
|
end
|
46
43
|
end
|
47
44
|
end
|
data/lib/active_flags/version.rb
CHANGED