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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: efe04e36b93c8278ea1c128e7aa38135d33468c904ad3434dbcc6c7dc7707478
4
- data.tar.gz: caaa81f78a086e6dba10e54f977018fbc19f5485559a59d15047a152d1780d9b
3
+ metadata.gz: 293861a0525887a1d226fe9c8673de534787fc243b6fa8c0feddc61e3cf7ff48
4
+ data.tar.gz: 4f2aecbe26c66918b393921e4f0666b34c62f2b8fc13d2c337d89789b86a22a3
5
5
  SHA512:
6
- metadata.gz: 75a96eb5ad3cea0bf65ec999ab14e27bbc081bc5e1315e231a9e1aac27c0db69caf1cc7820d1f782ba8cdcd25cc37606b6be0ea52abe8aa53b357781c1294217
7
- data.tar.gz: 87d6925a83d4faf2d544648d47b6c0caa82641fa25fcf0a138d35c0061a5a421aba6491c7391e9211101ded22f7308b18f49da5d73adf86143068450107bcad7
6
+ metadata.gz: dd3136e1b68d371109ea98957d9a09b18459f3086d14ec94d9f023cda5b81ae06ae477d180535014d1a3ba9d33541d215e62283b87c9e101ad3a85c115bde9cf
7
+ data.tar.gz: 4e866aed081ac5a526db9460c4b2ef148d0ee7ce17f5ffe758ef81cbbef6acb2970a7ec710ea4cc457825cb775c3a07bc7fdc46d1adc4ed0c04becd9e61a85c8
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Hachi
4
- VERSION = "0.2.2"
4
+ VERSION = "0.2.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hachi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manabu Niseki