bitwise_attribute 0.2.1 → 0.2.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: 1fa77b94797776f27660eb7fccbffc3ee0d1f9f10aebaecbfaa8725cca4b14e8
4
- data.tar.gz: fc96597734d8e93bc8656de1e0dd5819d2c075fe1a9fc958bee7377c2d198e1b
3
+ metadata.gz: 728afc2714df27029947e0f98b2c542ad8835bf44e052f720c588d22f2bcb821
4
+ data.tar.gz: 5e8fe818d69624b1888f954416a15f9cf938039067a5f67fea12eef73bf76e31
5
5
  SHA512:
6
- metadata.gz: 8d3ab3a732fe2bd157179231448713d6e65961b3f12c9cd52845296fd288536744a058dac2db6f9494b609e7879ed84b1695fe635c83ab9e1e161442dcffd328
7
- data.tar.gz: 82f83126bc932eca6c633038c27377dcceecaa7e25a6077a17060352a328645cd800656382d4dacb0b940a1aa1c01fe9467701e296828573854564ed81384e81
6
+ metadata.gz: 257fb003a2eb0421a5ca03b5b6cd32a2b4317c7172cb26a204e2516bc9b7aeb07989a99867bb5f33bbb6ccc6667f7bd88d5e1c116b18f6d782eee9dd469c5ece
7
+ data.tar.gz: 58b7153d9e3b51898d387252a1a91ed6f1514c778eff46f1941ed78cb4ff88b9d933131e493b4dbb184aaa27720d430335df741ba9a5ea103a66305b15d73a8e
@@ -15,4 +15,7 @@ Metrics/MethodLength:
15
15
  Max: 30
16
16
 
17
17
  Metrics/BlockLength:
18
- Max: 100
18
+ Max: 150
19
+
20
+ Metrics/ModuleLength:
21
+ Max: 200
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bitwise_attribute (0.2.1)
4
+ bitwise_attribute (0.2.2)
5
5
  activesupport (~> 5.1.5)
6
6
 
7
7
  GEM
@@ -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 |*vals|
30
- where(column_name => bitwise_union(vals, name))
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 |*vals|
34
- where(column_name => bitwise_intersection(vals, name))
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BitwiseAttribute
4
- VERSION = '0.2.1'
4
+ VERSION = '0.2.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.2.1
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-26 00:00:00.000000000 Z
11
+ date: 2018-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport