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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0f0f237297a8e24d935ba7d8a1e527be90905ce307bb0969f4da05f865ccf620
4
- data.tar.gz: a8759597c78d19d75ffac48269501fd8dfe7aa9d382c55324ef36b22557b74e6
3
+ metadata.gz: 210d7110d3dee1b1b94d976069ac36b475bee678932bc8ed210a21db00b517e1
4
+ data.tar.gz: 05abd969cd0f943e60763c757aa3dc1355af3b274999081cd69f5ecea64967ed
5
5
  SHA512:
6
- metadata.gz: cb1e364a63825b238ecd8c5c2fc45d52017544039b858cea80b8f2609104f19b90f974bbd2aaeff28b33589b8e1173a8b391ca5396ccc68d4d7f118db1461160
7
- data.tar.gz: ebca18a680d5b87ad721f626ad7cf7cbc3bb362d98845fc3d9144c4bdd70b3a2c8e3b5cdd867660e53ffaf4980b7a72a0c0518da9133afb43eb35673e7db0397
6
+ metadata.gz: 496aef69f89b52d018c44d31a7d06033b7098d5e013ad854928353675a41045d416ec92d3f7a0e28c845c12073b31ce4be488fb14ee661d47938262f4cad9bbc
7
+ data.tar.gz: 14c79726d07f71ba72daf0a35ae189c26daff795c221db6028a567c153c5002b40470a9c5c344c2f9c17c66aa9835e5bf4fa2e2a19e52da554aed4d103e29fb1
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bitwise_attribute (0.3.1)
4
+ bitwise_attribute (0.3.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BitwiseAttribute
4
- VERSION = '0.3.1'
4
+ VERSION = '0.3.2'
5
5
  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.1
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-30 00:00:00.000000000 Z
11
+ date: 2018-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord