hachi 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hachi/clients/base.rb +14 -0
- data/lib/hachi/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 293861a0525887a1d226fe9c8673de534787fc243b6fa8c0feddc61e3cf7ff48
|
4
|
+
data.tar.gz: 4f2aecbe26c66918b393921e4f0666b34c62f2b8fc13d2c337d89789b86a22a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd3136e1b68d371109ea98957d9a09b18459f3086d14ec94d9f023cda5b81ae06ae477d180535014d1a3ba9d33541d215e62283b87c9e101ad3a85c115bde9cf
|
7
|
+
data.tar.gz: 4e866aed081ac5a526db9460c4b2ef148d0ee7ce17f5ffe758ef81cbbef6acb2970a7ec710ea4cc457825cb775c3a07bc7fdc46d1adc4ed0c04becd9e61a85c8
|
data/lib/hachi/clients/base.rb
CHANGED
@@ -116,6 +116,7 @@ module Hachi
|
|
116
116
|
def _search(path, attributes:, range: "all")
|
117
117
|
validate_range range
|
118
118
|
|
119
|
+
attributes = normalize_attributes(attributes)
|
119
120
|
conditions = attributes.map do |key, value|
|
120
121
|
if key == :data && value.is_a?(Array)
|
121
122
|
{ _or: decompose_data(value) }
|
@@ -143,6 +144,19 @@ module Hachi
|
|
143
144
|
{ _field: "data", _value: elem }
|
144
145
|
end
|
145
146
|
end
|
147
|
+
|
148
|
+
def normalize_attributes(attributes)
|
149
|
+
h = {}
|
150
|
+
attributes.each do |key, value|
|
151
|
+
h[camelize(key).to_sym] = value
|
152
|
+
end
|
153
|
+
h
|
154
|
+
end
|
155
|
+
|
156
|
+
def camelize(string)
|
157
|
+
head, *others = string.to_s.split("_")
|
158
|
+
[head, others.map(&:capitalize)].flatten.join
|
159
|
+
end
|
146
160
|
end
|
147
161
|
end
|
148
162
|
end
|
data/lib/hachi/version.rb
CHANGED