rokaki 0.8.1.2 → 0.8.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: f371c83c5d42bd91e4f51363b7ec474807fceb3fb94dc7f9bd76bd067554d167
4
- data.tar.gz: 373f24755a5f2bd886aa56575b1f60f475db07db6a67b4716ed419a0896996eb
3
+ metadata.gz: b5484d6a4935bbc4f908e9081c82fcfd757f2e49770b7cbde2c055ec9ab169b0
4
+ data.tar.gz: 44a41e6c4ba814bc98934ddb2029a222841fd18425847c73ab3a9a3d86acc66a
5
5
  SHA512:
6
- metadata.gz: 200432e50f8d847fa7203760b7f52cbfd6743dfdb4247388dfe5e636b79331acec739759fe65b52ebde23585eb90ffbada5802cf5be2f19431410bd612c084f3
7
- data.tar.gz: 49207149db07210dc0c55fdfbf976737a404e4c255acff2484347b53339d8b18d2ed9f6bd0ca3a5efc2a79b583bf4f6489583cbc586ecce30aa1bde498201881
6
+ metadata.gz: e8c29246d64a0fc0c5ca63173c419cee77cf07cd06d99a1fc14bcc53285222d980e8ace9e624bb75d4566814bfc8ce38613305676d2152591da83f8ea04002b1
7
+ data.tar.gz: 82ac3f4b16473b8adf6aeeb93907a0e71ab811c439d5071e95b063238042828c39818f33763a953fa0898c40c0d0f912cc6b3781b9ff1bb75d6c3227c8efd282
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rokaki (0.8.1.2)
4
+ rokaki (0.8.2)
5
5
  activesupport
6
6
 
7
7
  GEM
@@ -30,7 +30,6 @@ module Rokaki
30
30
  @filter_map_query_key = query_key
31
31
 
32
32
  @_filter_db = options[:db] || :postgres
33
- @_filter_mode = options[:mode] || :and
34
33
  like(options[:like]) if options[:like]
35
34
  ilike(options[:ilike]) if options[:ilike]
36
35
  filters(*options[:match]) if options[:match]
@@ -41,7 +40,6 @@ module Rokaki
41
40
  @filter_map_query_key = nil
42
41
 
43
42
  @_filter_db = options[:db] || :postgres
44
- @_filter_mode = options[:mode] || :and
45
43
  like(options[:like]) if options[:like]
46
44
  ilike(options[:ilike]) if options[:ilike]
47
45
  filters(*options[:match]) if options[:match]
@@ -16,15 +16,16 @@ module Rokaki
16
16
 
17
17
  def call
18
18
  args.keys.each do |key|
19
- like_keys << map_keys(args[key], key)
19
+ map_keys(args[key], key)
20
20
  end
21
21
  like_keys
22
22
  end
23
23
 
24
24
  private
25
25
 
26
- def map_keys(value, key)
26
+ def map_keys(value, key, key_path = [])
27
27
  key_result = {}
28
+ key_path << key
28
29
 
29
30
  if value.is_a? Hash
30
31
  value.keys.each do |sub_key|
@@ -35,18 +36,26 @@ module Rokaki
35
36
  key_result[key] << sub_key
36
37
  else
37
38
  key_result[key] = [ sub_key ]
39
+ @like_keys << deep_assign(key_path, key_result[key])
38
40
  end
39
41
 
40
42
  elsif sub_value.is_a? Hash
41
- key_result[key] = map_keys(sub_value, sub_key)
43
+ map_keys(sub_value, sub_key, key_path)
42
44
  end
43
45
  end
44
46
  else
45
- key_result = key
47
+ @like_keys = [key]
46
48
  end
47
49
 
48
50
  key_result
49
51
  end
52
+
53
+ # Many thanks Cary Swoveland
54
+ # https://stackoverflow.com/questions/56634950/ruby-dig-set-assign-values-using-hashdig/56635124
55
+ #
56
+ def deep_assign(keys, value)
57
+ keys[0..-2].reverse_each.reduce ({ keys.last => value }) { |h,key| { key=>h } }
58
+ end
50
59
  end
51
60
  end
52
61
  end
@@ -4,7 +4,7 @@ require 'active_support/inflector'
4
4
  module Rokaki
5
5
  module FilterModel
6
6
  class NestedFilter
7
- def initialize(filter_key_object:, prefix:, infix:, like_semantics:, i_like_semantics:, db:, mode: :and)
7
+ def initialize(filter_key_object:, prefix:, infix:, like_semantics:, i_like_semantics:, db:)
8
8
  @filter_key_object = filter_key_object
9
9
  @prefix = prefix
10
10
  @infix = infix
@@ -13,9 +13,8 @@ module Rokaki
13
13
  @filter_methods = []
14
14
  @filter_templates = []
15
15
  @db = db
16
- @mode = mode
17
16
  end
18
- attr_reader :filter_key_object, :prefix, :infix, :like_semantics, :i_like_semantics, :db, :mode
17
+ attr_reader :filter_key_object, :prefix, :infix, :like_semantics, :i_like_semantics, :db
19
18
  attr_accessor :filter_methods, :filter_templates
20
19
 
21
20
  def call # _chain_nested_filter
@@ -1,3 +1,3 @@
1
1
  module Rokaki
2
- VERSION = "0.8.1.2"
2
+ VERSION = "0.8.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rokaki
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1.2
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Martin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-21 00:00:00.000000000 Z
11
+ date: 2020-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport