bitmasker 0.3.2 → 0.3.3

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
  SHA1:
3
- metadata.gz: e791e75331fc95bfeaa6a78b546d9ebefa5060d3
4
- data.tar.gz: 1936a77afe674e2fdd355a5194a1200a09be30ca
3
+ metadata.gz: 3327d3117745cfaa460b5a7ff0df3a13751bbb2e
4
+ data.tar.gz: f50d87dffe865430578865c3575abf45c108d7cc
5
5
  SHA512:
6
- metadata.gz: 95ac3d11a288dbe0e743f5b0422bb07a8fd877bfeb519c16e93676cc1c8b044b11313a47d4ce6f8a851fd58ac28fa72ebe543ee4c2b7b8dc52bc809134a1e822
7
- data.tar.gz: c6ca3c910115b6a95f40be1fe9e9e5d8954edad1bab6d9f0a1854390696fbdb79c092547a43c947a1bfabcd404bafb27a3895eabb01f53fb8d44933cabbc2b43
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
@@ -1,3 +1,3 @@
1
1
  module Bitmasker
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
@@ -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
- send_weekly_email: 0b0001,
27
- send_monthly_newsletter: 0b0010,
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.2
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-07-23 00:00:00.000000000 Z
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: