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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f9294a75b725745829acd3ec8aaa51f38a7e33fcac56c0a54691e30d710aa412
4
- data.tar.gz: 150a55111a05c5a9760bd0a8b5d7c3b5f84a5121ac9a20dfe4d94b75156e5d2a
3
+ metadata.gz: a5e9e8a7d28e9b72164485acc16beb6e5e41fe28bb47fb80d98d2a9337d17b99
4
+ data.tar.gz: 53926a68eff6f2ecf294fd076ec0616c159f57fe4137d785999a5a831d165275
5
5
  SHA512:
6
- metadata.gz: d83b4c732a65d57a6ed19338212f323ca54c91a5a51b2c583f49dd5adc7fef6525d42661ef09ab1131f65c0ef1ee55f91a470ca2ea19a826e525eec280cfd42f
7
- data.tar.gz: 0c39dc87352e7fc6508d3df4588487be544c440cdaa706e33e01f57781fb77e3c4c0914df8c12fd353637541bfa1b5cd83db9d69adf22686816d4a6142aedf66
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
- condition = { active_flags_flags: { value: stringify(args[0]) } }
38
+ result = joins(:flags_as_collection)
39
+ .where(active_flags_flags: { key: flag, value: stringify(args[0]) })
40
40
 
41
- joins(:flags_as_collection)
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
@@ -1,3 +1,3 @@
1
1
  module ActiveFlags
2
- VERSION = '0.3.3'
2
+ VERSION = '0.3.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_flags
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Huberty