azahara_schema 0.1.16 → 0.1.17
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a14e9a8c3362597472cda8ccc365c47e818fb89f905c8ab6aa682763c329536d
|
4
|
+
data.tar.gz: 7b42eaacf12b867c599eaecd3a5d8f5bf6203dbeab5b178b029392a2b4164c98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b25f86081f3b3985bd4840695d8f41bcc4c673228db1a394df1aa095f106fe82884e33873723a481ae02d6b4881fdac6459e5451981f3d09aad246b65b1aae82
|
7
|
+
data.tar.gz: 22da5b868389f86c35e7af515673494416c4a3ac8ecbf25d47a361f7dac30a5b349bdc00a77628dfe760e7cd09b91c5a269b296bb46f34358d72dd8a5bd97178
|
@@ -69,9 +69,15 @@ module AzaharaSchema
|
|
69
69
|
|
70
70
|
# values has to be array!
|
71
71
|
def arel_statement(operator, values)
|
72
|
+
values = values.collect{|v| format.sanitize_value(v) }
|
72
73
|
case operator
|
73
74
|
when '='
|
74
|
-
arel_field.in(values)
|
75
|
+
condition = arel_field.in(values.compact) if values.compact.any?
|
76
|
+
if values.include?(nil)
|
77
|
+
c_nil = arel_field.eq(nil)
|
78
|
+
condition = condition ? condition.or(c_nil) : c_nil
|
79
|
+
end
|
80
|
+
condition
|
75
81
|
when '~'
|
76
82
|
vals = values.collect{|v| v.split }.flatten
|
77
83
|
arl = arel_field.matches("%#{vals[0]}%")
|
@@ -55,6 +55,10 @@ module AzaharaSchema
|
|
55
55
|
def searchable?
|
56
56
|
false
|
57
57
|
end
|
58
|
+
|
59
|
+
def sanitize_value(value)
|
60
|
+
value
|
61
|
+
end
|
58
62
|
end
|
59
63
|
|
60
64
|
class NumberFormat < Base
|
@@ -69,6 +73,10 @@ module AzaharaSchema
|
|
69
73
|
|
70
74
|
class IntegerFormat < NumberFormat
|
71
75
|
add 'integer'
|
76
|
+
|
77
|
+
def sanitize_value(value)
|
78
|
+
value.to_s.present? ? value.to_s.to_i : nil
|
79
|
+
end
|
72
80
|
end
|
73
81
|
|
74
82
|
class FloatFormat < NumberFormat
|
@@ -93,6 +101,10 @@ module AzaharaSchema
|
|
93
101
|
def searchable?
|
94
102
|
true
|
95
103
|
end
|
104
|
+
|
105
|
+
def sanitize_value(value)
|
106
|
+
value.to_s.presence
|
107
|
+
end
|
96
108
|
end
|
97
109
|
|
98
110
|
class ListFormat < StringFormat
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: azahara_schema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ondřej Ezr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|