bitwise_attribute 0.2.1 → 0.2.2
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 +4 -4
- data/.rubocop.yml +4 -1
- data/Gemfile.lock +1 -1
- data/lib/bitwise_attribute.rb +19 -4
- 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: 728afc2714df27029947e0f98b2c542ad8835bf44e052f720c588d22f2bcb821
|
4
|
+
data.tar.gz: 5e8fe818d69624b1888f954416a15f9cf938039067a5f67fea12eef73bf76e31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 257fb003a2eb0421a5ca03b5b6cd32a2b4317c7172cb26a204e2516bc9b7aeb07989a99867bb5f33bbb6ccc6667f7bd88d5e1c116b18f6d782eee9dd469c5ece
|
7
|
+
data.tar.gz: 58b7153d9e3b51898d387252a1a91ed6f1514c778eff46f1941ed78cb4ff88b9d933131e493b4dbb184aaa27720d430335df741ba9a5ea103a66305b15d73a8e
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
data/lib/bitwise_attribute.rb
CHANGED
@@ -21,19 +21,34 @@ module BitwiseAttribute
|
|
21
21
|
@mapping ||= {}
|
22
22
|
@mapping[name] = mapping
|
23
23
|
|
24
|
+
define_class_methods(name, column_name, mapping)
|
25
|
+
define_instante_methods(name, column_name, mapping)
|
26
|
+
end
|
27
|
+
|
28
|
+
def define_class_methods(name, column_name, mapping)
|
24
29
|
# Class methods
|
25
30
|
define_singleton_method(name) do
|
26
31
|
mapping
|
27
32
|
end
|
28
33
|
|
29
|
-
define_singleton_method("with_#{name}") do |*
|
30
|
-
where(column_name => bitwise_union(
|
34
|
+
define_singleton_method("with_#{name}") do |*keys|
|
35
|
+
where(column_name => bitwise_union(keys, name))
|
31
36
|
end
|
32
37
|
|
33
|
-
define_singleton_method("with_all_#{name}") do |*
|
34
|
-
where(column_name => bitwise_intersection(
|
38
|
+
define_singleton_method("with_all_#{name}") do |*keys|
|
39
|
+
where(column_name => bitwise_intersection(keys, name))
|
35
40
|
end
|
36
41
|
|
42
|
+
# Defines a class method for each key of the mapping, returning records that have *at least*
|
43
|
+
# the corresponding value.
|
44
|
+
mapping.keys.each do |key|
|
45
|
+
define_singleton_method(key) do
|
46
|
+
send("with_#{key}")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def define_instante_methods(name, column_name, mapping)
|
37
52
|
define_method(name) do
|
38
53
|
roles = value_getter(column_name, mapping)
|
39
54
|
|
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.2.
|
4
|
+
version: 0.2.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-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|