rokaki 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +1 -0
- data/lib/rokaki/filter_model/like.rb +0 -34
- data/lib/rokaki/filter_model.rb +2 -30
- data/lib/rokaki/version.rb +1 -1
- data/lib/rokaki.rb +1 -0
- 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: e5d32983f1791295aadabcc64fafca2e7cda63e679b0e37fcf38fc41085679e5
|
4
|
+
data.tar.gz: f1125b9db501745d1d3cad0da31b378f90fd1e5b44b2cdf0e8a2429eea91dea2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fcac7ca5e906933335255fb59c63b2e8114a864cd8a6c9f2868c9e64a25566c6c00d9439c01dc372b123443e953cd45930ceb93bc80cd43dc3f6da48ad029f83
|
7
|
+
data.tar.gz: c9f3742c1ec502b04453ab373eff82646c67b8d134981b67838666f185d5b6d36fefc0371ee386d60fda6a17f6e2e90d52a17e6de5963bb501d365a8e4eb4c24
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Rokaki
|
4
|
-
module FilterModel
|
5
|
-
module Like
|
6
|
-
def self.included(base)
|
7
|
-
base.extend(ClassMethods)
|
8
|
-
end
|
9
|
-
|
10
|
-
module ClassMethods
|
11
|
-
def like(args)
|
12
|
-
raise ArgumentError, 'argument mush be a hash' unless args.is_a? Hash
|
13
|
-
@_like_semantics = (@_like_semantics || {}).merge(args)
|
14
|
-
end
|
15
|
-
|
16
|
-
def _chain_filter_like_type(key)
|
17
|
-
filter = "#{filter_key_prefix}#{key}"
|
18
|
-
|
19
|
-
query = "@model.where(\"#{key} LIKE :query\", "
|
20
|
-
if mode == :circumfix
|
21
|
-
query += "query: \"%\#{#{filter}}%\")"
|
22
|
-
end
|
23
|
-
if mode == :infix
|
24
|
-
query += "query: \"%\#{#{filter}}\")"
|
25
|
-
end
|
26
|
-
if mode == :suffix
|
27
|
-
query += "query: \"\#{#{filter}}%\")"
|
28
|
-
end
|
29
|
-
"#{query};"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
data/lib/rokaki/filter_model.rb
CHANGED
@@ -113,39 +113,11 @@ module Rokaki
|
|
113
113
|
|
114
114
|
def like(args)
|
115
115
|
raise ArgumentError, 'argument mush be a hash' unless args.is_a? Hash
|
116
|
-
|
117
|
-
like_keys = {base: []}
|
118
|
-
args.keys.each do |key|
|
119
|
-
map_like_keys(like_keys, args, key)
|
120
|
-
end
|
121
|
-
|
122
116
|
@_like_semantics = (@_like_semantics || {}).merge(args)
|
123
117
|
|
124
|
-
|
125
|
-
key_results = base_keys << like_keys
|
118
|
+
key_builder = LikeKeys.new(args)
|
126
119
|
|
127
|
-
filters(*
|
128
|
-
end
|
129
|
-
|
130
|
-
def map_like_keys(key_result, base_object, key)
|
131
|
-
sub_object = base_object[key]
|
132
|
-
if sub_object.is_a? Hash
|
133
|
-
sub_object.keys.each do |sub_key|
|
134
|
-
sub_object_value = sub_object[sub_key]
|
135
|
-
if sub_object_value.is_a? Symbol
|
136
|
-
if key_result[key].is_a? Array
|
137
|
-
key_result[key] << sub_key
|
138
|
-
else
|
139
|
-
key_result[key] = [sub_key]
|
140
|
-
end
|
141
|
-
elsif sub_object_value.is_a? Hash
|
142
|
-
map_like_keys(key_result, sub_object, sub_key)
|
143
|
-
end
|
144
|
-
end
|
145
|
-
elsif sub_object.is_a? Symbol
|
146
|
-
key_result[:base] << key
|
147
|
-
end
|
148
|
-
key_result
|
120
|
+
filters(*key_builder.call)
|
149
121
|
end
|
150
122
|
|
151
123
|
def deep_chain(keys, value)
|
data/lib/rokaki/version.rb
CHANGED
data/lib/rokaki.rb
CHANGED
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.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Martin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|