rokaki 0.8.1 → 0.8.1.1

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: 8a4312a80ff21e5c59187f2677c803626aa2d9bd2331316dea46de60461c50fa
4
- data.tar.gz: f2d1b2b2aeefb8f82cf7be3ecfe5f058472701ad23064a8909fe09e6c289e4d7
3
+ metadata.gz: 44e54fda626422f9ed27d25aa30aa7f6303722a16b0bb931b6aeead9965b380f
4
+ data.tar.gz: 2b5a2ea0ce4284e84fcf006071b5831e41df8dfbd83399be23fd62f2cae7ad9c
5
5
  SHA512:
6
- metadata.gz: c4d9d19c3d0f008721cfe2cbae3364f29e46fc094edd03af7738999a5cbe3680606f9201d884d4ce1316d5ad3da54b1f572d8bec7bcc3a00cc60696e36a0db11
7
- data.tar.gz: 2c83644c0338d9024422de614edb92d336ec542261f3453b07f5713e676e8c0c6c5947e8e75fb85bfde6f862185f56a9eac44664ea6769767dda2e901937b9ea
6
+ metadata.gz: '039a420452518968761d8eff610603a643825fa98de17d51cb038f6fcd79f4870b898688c5bbc6fc61a193ccc21a6cd86b7a50027aa6219520fa1cd3b25469d6'
7
+ data.tar.gz: 5c69385b228a28f6378b2c8a4e584e597c6e80b5781b634fd8ca977e16f67d65c64c4ca16a1f6ff2bfe6c0cd3a55410033eabe2ac8f195fc46d23cba2ac7c624
@@ -27,9 +27,10 @@ module Rokaki
27
27
 
28
28
  def filter_map(model, query_key, options)
29
29
  filter_model(model)
30
- @_query_key = query_key
30
+ @filter_map_query_key = query_key
31
31
 
32
32
  @_filter_db = options[:db] || :postgres
33
+ @_filter_mode = options[:mode] || :and
33
34
  like(options[:like]) if options[:like]
34
35
  ilike(options[:ilike]) if options[:ilike]
35
36
  filters(*options[:match]) if options[:match]
@@ -37,16 +38,18 @@ module Rokaki
37
38
 
38
39
  def filter(model, options)
39
40
  filter_model(model)
41
+ @filter_map_query_key = nil
40
42
 
41
43
  @_filter_db = options[:db] || :postgres
44
+ @_filter_mode = options[:mode] || :and
42
45
  like(options[:like]) if options[:like]
43
46
  ilike(options[:ilike]) if options[:ilike]
44
47
  filters(*options[:match]) if options[:match]
45
48
  end
46
49
 
47
50
  def filters(*filter_keys)
48
- if @_query_key
49
- define_filter_map(@_query_key, *filter_keys)
51
+ if @filter_map_query_key
52
+ define_filter_map(@filter_map_query_key, *filter_keys)
50
53
  else
51
54
  define_filter_keys(*filter_keys)
52
55
  end
@@ -100,9 +103,9 @@ module Rokaki
100
103
  end
101
104
  end
102
105
 
103
- def associated_table(association)
104
- @model.reflect_on_association(association).klass.table_name
105
- end
106
+ # def associated_table(association)
107
+ # @model.reflect_on_association(association).klass.table_name
108
+ # end
106
109
 
107
110
  def filter_model(model_class)
108
111
  @model = (model_class.is_a?(Class) ? model_class : Object.const_get(model_class.capitalize))
@@ -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:)
7
+ def initialize(filter_key_object:, prefix:, infix:, like_semantics:, i_like_semantics:, db:, mode: :and)
8
8
  @filter_key_object = filter_key_object
9
9
  @prefix = prefix
10
10
  @infix = infix
@@ -13,8 +13,9 @@ module Rokaki
13
13
  @filter_methods = []
14
14
  @filter_templates = []
15
15
  @db = db
16
+ @mode = mode
16
17
  end
17
- attr_reader :filter_key_object, :prefix, :infix, :like_semantics, :i_like_semantics, :db
18
+ attr_reader :filter_key_object, :prefix, :infix, :like_semantics, :i_like_semantics, :db, :mode
18
19
  attr_accessor :filter_methods, :filter_templates
19
20
 
20
21
  def call # _chain_nested_filter
@@ -56,7 +57,7 @@ module Rokaki
56
57
  end
57
58
 
58
59
  def find_i_like_key(keys)
59
- return nil unless like_semantics && i_like_semantics.keys.any?
60
+ return nil unless i_like_semantics && i_like_semantics.keys.any?
60
61
  current_like_key = i_like_semantics
61
62
  keys.each do |key|
62
63
  current_like_key = current_like_key[key]
@@ -23,6 +23,10 @@ module Rokaki
23
23
  end
24
24
  end
25
25
 
26
+ def define_query_key(key = nil)
27
+ @filter_map_query_key = key
28
+ end
29
+
26
30
  def filter_key_prefix(prefix = nil)
27
31
  @filter_key_prefix ||= prefix
28
32
  end
@@ -1,3 +1,3 @@
1
1
  module Rokaki
2
- VERSION = "0.8.1"
2
+ VERSION = "0.8.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rokaki
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Martin