bitwise_attribute 0.3.1 → 0.3.2
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 +8 -6
- data/lib/bitwise_attribute/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 210d7110d3dee1b1b94d976069ac36b475bee678932bc8ed210a21db00b517e1
|
4
|
+
data.tar.gz: 05abd969cd0f943e60763c757aa3dc1355af3b274999081cd69f5ecea64967ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 496aef69f89b52d018c44d31a7d06033b7098d5e013ad854928353675a41045d416ec92d3f7a0e28c845c12073b31ce4be488fb14ee661d47938262f4cad9bbc
|
7
|
+
data.tar.gz: 14c79726d07f71ba72daf0a35ae189c26daff795c221db6028a567c153c5002b40470a9c5c344c2f9c17c66aa9835e5bf4fa2e2a19e52da554aed4d103e29fb1
|
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 = cleanup_keys(keys)
|
7
|
+
keys = cleanup_keys(keys, mapping)
|
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 = cleanup_keys(keys)
|
21
|
+
keys = cleanup_keys(keys, mapping)
|
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 = cleanup_keys(keys)
|
35
|
+
keys = cleanup_keys(keys, mapping)
|
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 = cleanup_keys(keys)
|
49
|
+
keys = cleanup_keys(keys, mapping)
|
50
50
|
|
51
51
|
return where(column_name => nil).or(where(column_name => 0)) unless keys&.any?
|
52
52
|
|
@@ -68,10 +68,12 @@ module BitwiseAttribute
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
def cleanup_keys(keys)
|
71
|
+
def cleanup_keys(keys, mapping)
|
72
72
|
return [] unless keys
|
73
73
|
|
74
|
-
keys.flatten.map(&:to_sym).uniq
|
74
|
+
clean = keys.flatten.map(&:to_sym).compact.uniq
|
75
|
+
|
76
|
+
clean & mapping.keys # only roles that we know about
|
75
77
|
end
|
76
78
|
end
|
77
79
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitwise_attribute
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ricardo Otero
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|