bitmasker 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3327d3117745cfaa460b5a7ff0df3a13751bbb2e
|
4
|
+
data.tar.gz: f50d87dffe865430578865c3575abf45c108d7cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 248288410e9236506b9493bb8b314c0ccdbf264ef66159e6311513dbe66e020588ad0f28f9ed24d40746361cfaa5d01c714083ffcd4bbc0448a4b98b48c40f36
|
7
|
+
data.tar.gz: cbcc80163968f5b1edf523da7bce6b0a98aa7aa8da0e4a9f343f491f1619900cc8dee61bfcefb16ccf9aee9a862740fdbcd20e772e05edb303c16a545f8b79f3
|
@@ -55,9 +55,14 @@ module Bitmasker
|
|
55
55
|
mask = bitmask
|
56
56
|
mask.set_array(Array.wrap(attributes).flatten.map(&:to_s))
|
57
57
|
|
58
|
+
return null_query if mask.to_i.zero?
|
59
|
+
|
58
60
|
# TODO: Test lots of databases
|
59
61
|
model_class.where(query, mask: mask.to_i)
|
60
62
|
end
|
61
63
|
|
64
|
+
def null_query
|
65
|
+
model_class.where('1 = 0')
|
66
|
+
end
|
62
67
|
end
|
63
68
|
end
|
data/lib/bitmasker/version.rb
CHANGED
@@ -22,9 +22,11 @@ class Bitmasker::BitmaskAttributesTest < MiniTest::Unit::TestCase
|
|
22
22
|
|
23
23
|
def setup
|
24
24
|
@klass = Bitmasker::BitmaskAttributes.make(
|
25
|
-
MockModel, 'email_mask',
|
26
|
-
|
27
|
-
|
25
|
+
MockModel, 'email_mask', {
|
26
|
+
send_weekly_email: 0b0001,
|
27
|
+
send_monthly_newsletter: 0b0010,
|
28
|
+
send_awesome_email: 0b0100,
|
29
|
+
}, { send_awesome_email: true },
|
28
30
|
)
|
29
31
|
end
|
30
32
|
|
@@ -54,4 +54,9 @@ class Bitmasker::BitmaskScopeTest < MiniTest::Unit::TestCase
|
|
54
54
|
MockModel.expects(:where).with("mock_models.email_mask & :mask <> 0", mask: 3)
|
55
55
|
subject.with_any_emails([:send_weekly_email, :send_monthly_newsletter])
|
56
56
|
end
|
57
|
+
|
58
|
+
def test_with_unmatching_attribute
|
59
|
+
MockModel.expects(:where).with("1 = 0")
|
60
|
+
subject.with_emails(:omg_not_an_attribute)
|
61
|
+
end
|
57
62
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitmasker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Amiel Martin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bitmask
|
@@ -149,3 +149,4 @@ test_files:
|
|
149
149
|
- test/bitmasker/bitmask_scope_test.rb
|
150
150
|
- test/integration_test.rb
|
151
151
|
- test/test_helper.rb
|
152
|
+
has_rdoc:
|