bitwise_attribute 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/bitwise_attribute/active_record_methods.rb +10 -4
- data/lib/bitwise_attribute/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: 0f0f237297a8e24d935ba7d8a1e527be90905ce307bb0969f4da05f865ccf620
|
4
|
+
data.tar.gz: a8759597c78d19d75ffac48269501fd8dfe7aa9d382c55324ef36b22557b74e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb1e364a63825b238ecd8c5c2fc45d52017544039b858cea80b8f2609104f19b90f974bbd2aaeff28b33589b8e1173a8b391ca5396ccc68d4d7f118db1461160
|
7
|
+
data.tar.gz: ebca18a680d5b87ad721f626ad7cf7cbc3bb362d98845fc3d9144c4bdd70b3a2c8e3b5cdd867660e53ffaf4980b7a72a0c0518da9133afb43eb35673e7db0397
|
data/Gemfile.lock
CHANGED
@@ -4,7 +4,7 @@ module BitwiseAttribute
|
|
4
4
|
module ActiveRecordMethods
|
5
5
|
def define_named_scopes(name, column_name, mapping)
|
6
6
|
define_singleton_method("with_#{name}") do |*keys|
|
7
|
-
keys = keys
|
7
|
+
keys = cleanup_keys(keys)
|
8
8
|
|
9
9
|
return [] unless keys&.any?
|
10
10
|
|
@@ -18,7 +18,7 @@ module BitwiseAttribute
|
|
18
18
|
end
|
19
19
|
|
20
20
|
define_singleton_method("with_any_#{name}") do |*keys|
|
21
|
-
keys = keys
|
21
|
+
keys = cleanup_keys(keys)
|
22
22
|
|
23
23
|
return where.not(column_name => nil) unless keys&.any?
|
24
24
|
|
@@ -32,7 +32,7 @@ module BitwiseAttribute
|
|
32
32
|
end
|
33
33
|
|
34
34
|
define_singleton_method("with_exact_#{name}") do |*keys|
|
35
|
-
keys = keys
|
35
|
+
keys = cleanup_keys(keys)
|
36
36
|
|
37
37
|
return [] unless keys&.any?
|
38
38
|
|
@@ -46,7 +46,7 @@ module BitwiseAttribute
|
|
46
46
|
end
|
47
47
|
|
48
48
|
define_singleton_method("without_#{name}") do |*keys|
|
49
|
-
keys = keys
|
49
|
+
keys = cleanup_keys(keys)
|
50
50
|
|
51
51
|
return where(column_name => nil).or(where(column_name => 0)) unless keys&.any?
|
52
52
|
|
@@ -67,5 +67,11 @@ module BitwiseAttribute
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
70
|
+
|
71
|
+
def cleanup_keys(keys)
|
72
|
+
return [] unless keys
|
73
|
+
|
74
|
+
keys.flatten.map(&:to_sym).uniq
|
75
|
+
end
|
70
76
|
end
|
71
77
|
end
|