bitmasker 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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e791e75331fc95bfeaa6a78b546d9ebefa5060d3
|
4
|
+
data.tar.gz: 1936a77afe674e2fdd355a5194a1200a09be30ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95ac3d11a288dbe0e743f5b0422bb07a8fd877bfeb519c16e93676cc1c8b044b11313a47d4ce6f8a851fd58ac28fa72ebe543ee4c2b7b8dc52bc809134a1e822
|
7
|
+
data.tar.gz: c6ca3c910115b6a95f40be1fe9e9e5d8954edad1bab6d9f0a1854390696fbdb79c092547a43c947a1bfabcd404bafb27a3895eabb01f53fb8d44933cabbc2b43
|
@@ -7,6 +7,7 @@ module Bitmasker
|
|
7
7
|
|
8
8
|
class_attribute :model_class
|
9
9
|
class_attribute :field_name
|
10
|
+
class_attribute :table_name
|
10
11
|
class_attribute :mask_name
|
11
12
|
class_attribute :bitmask_attributes
|
12
13
|
|
@@ -20,6 +21,7 @@ module Bitmasker
|
|
20
21
|
end
|
21
22
|
|
22
23
|
klass.model_class = model_class
|
24
|
+
klass.table_name = model_class.table_name
|
23
25
|
klass.field_name = field_name
|
24
26
|
klass.mask_name = mask_name
|
25
27
|
klass.bitmask_attributes = bitmask_attributes.stringify_keys
|
@@ -34,17 +36,17 @@ module Bitmasker
|
|
34
36
|
# REVIEW: This (the unused _ attribute) tells me I have the design wrong
|
35
37
|
def with_attribute(_, *attributes)
|
36
38
|
# TODO: Test lots of databases
|
37
|
-
bitmask_query attributes, "#{field_name} & :mask = :mask"
|
39
|
+
bitmask_query attributes, "#{table_name}.#{field_name} & :mask = :mask"
|
38
40
|
end
|
39
41
|
|
40
42
|
def with_any_attribute(_, *attributes)
|
41
43
|
# TODO: Test lots of databases
|
42
|
-
bitmask_query attributes, "#{field_name} & :mask <> 0"
|
44
|
+
bitmask_query attributes, "#{table_name}.#{field_name} & :mask <> 0"
|
43
45
|
end
|
44
46
|
|
45
47
|
def without_attribute(_, *attributes)
|
46
48
|
# TODO: Test lots of databases
|
47
|
-
bitmask_query attributes, "#{field_name} & :mask = 0 OR #{field_name} IS NULL"
|
49
|
+
bitmask_query attributes, "#{table_name}.#{field_name} & :mask = 0 OR #{table_name}.#{field_name} IS NULL"
|
48
50
|
end
|
49
51
|
|
50
52
|
private
|
data/lib/bitmasker/version.rb
CHANGED
@@ -2,7 +2,11 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
class Bitmasker::BitmaskScopeTest < MiniTest::Unit::TestCase
|
4
4
|
|
5
|
-
MockModel = Class.new
|
5
|
+
MockModel = Class.new do
|
6
|
+
def self.table_name
|
7
|
+
"mock_models"
|
8
|
+
end
|
9
|
+
end
|
6
10
|
|
7
11
|
def model_instance
|
8
12
|
@model_instance ||= MockModel.new
|
@@ -27,27 +31,27 @@ class Bitmasker::BitmaskScopeTest < MiniTest::Unit::TestCase
|
|
27
31
|
|
28
32
|
|
29
33
|
def test_with_attribute
|
30
|
-
MockModel.expects(:where).with("email_mask & :mask = :mask", mask: 1)
|
34
|
+
MockModel.expects(:where).with("mock_models.email_mask & :mask = :mask", mask: 1)
|
31
35
|
subject.with_emails(:send_weekly_email)
|
32
36
|
end
|
33
37
|
|
34
38
|
def test_with_attributes_array
|
35
|
-
MockModel.expects(:where).with("email_mask & :mask = :mask", mask: 6)
|
39
|
+
MockModel.expects(:where).with("mock_models.email_mask & :mask = :mask", mask: 6)
|
36
40
|
subject.with_emails([:send_monthly_newsletter, :send_daily_spam])
|
37
41
|
end
|
38
42
|
|
39
43
|
def test_with_attributes
|
40
|
-
MockModel.expects(:where).with("email_mask & :mask = :mask", mask: 6)
|
44
|
+
MockModel.expects(:where).with("mock_models.email_mask & :mask = :mask", mask: 6)
|
41
45
|
subject.with_emails(:send_monthly_newsletter, :send_daily_spam)
|
42
46
|
end
|
43
47
|
|
44
48
|
def test_without_attribute
|
45
|
-
MockModel.expects(:where).with("email_mask & :mask = 0 OR email_mask IS NULL", mask: 2)
|
49
|
+
MockModel.expects(:where).with("mock_models.email_mask & :mask = 0 OR mock_models.email_mask IS NULL", mask: 2)
|
46
50
|
subject.without_emails(:send_monthly_newsletter)
|
47
51
|
end
|
48
52
|
|
49
53
|
def test_with_any_attribute
|
50
|
-
MockModel.expects(:where).with("email_mask & :mask <> 0", mask: 3)
|
54
|
+
MockModel.expects(:where).with("mock_models.email_mask & :mask <> 0", mask: 3)
|
51
55
|
subject.with_any_emails([:send_weekly_email, :send_monthly_newsletter])
|
52
56
|
end
|
53
57
|
end
|
data/test/integration_test.rb
CHANGED
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.2
|
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-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bitmask
|