lhc 9.4.3 → 9.4.4

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: a020f77f047005cae5e2783018a8e845a619ae594d7c2567e2eb20cb6d71f965
4
- data.tar.gz: 105f2df6c51e19750bf4c180382be1c4f2fe9865c7a82ff5708ead4362212858
3
+ metadata.gz: 35f64115a3a18dcad3d0494af2afe221aba124a22358f3be7b27dad63ccca55c
4
+ data.tar.gz: 14e25b16e6053a1db7db44dde741a1c48a715b0fc64e9865fe18cbd755baa976
5
5
  SHA512:
6
- metadata.gz: f288a674f51be5c50be0b013b637af67c81138453af9f5d043b075898ce76ce2d4b1275a77e180bb53849eacc1c96b990f1c9ca8eb6e77c19ee79a35c15e3fe4
7
- data.tar.gz: 2f9a0c9e3a7563759d069d861fc96337e27733c653c066a512f3d28e7a263decab10c707f20ba850230402a22e83412ccdfb447f0741985d02b0f8a1359127a5
6
+ metadata.gz: 9fa8c49a2b87857e7f44746166f60ad0ab572520a005fbbce14e5a7909c2f661bd8ab1f3f6becc55a1d54b9d89879c3221d9062edf8c5575de38505e857e1323
7
+ data.tar.gz: 46d331a87f5acfdd8bbea6b139cb6d9dacbbce0a3757d2f8be36299bba544b5a78e5f0753504e31da12a92627718e2b49b59aaf9962b67297a54308af467a011
@@ -109,8 +109,8 @@ class LHC::Request
109
109
  def generate_url_from_template!
110
110
  endpoint = LHC::Endpoint.new(options[:url])
111
111
  params =
112
- if format && options[:body]&.length && options[:body].is_a?(Hash)
113
- options[:body].merge(options[:params] || {}).deep_symbolize_keys
112
+ if format && options[:body].present? && options[:body].respond_to?(:as_json) && options[:body].as_json.is_a?(Hash)
113
+ options[:body].as_json.merge(options[:params] || {}).deep_symbolize_keys
114
114
  else
115
115
  options[:params]
116
116
  end
@@ -1,3 +1,3 @@
1
1
  module LHC
2
- VERSION ||= '9.4.3'
2
+ VERSION ||= '9.4.4'
3
3
  end
@@ -20,4 +20,33 @@ describe LHC::Request do
20
20
  stub_request(:post, "http://datastore:8080/v2/places/123")
21
21
  LHC.json.post('http://datastore:8080/v2/places/{id}', body: { id: 123 })
22
22
  end
23
+
24
+ context 'custom data structures that respond to as_json (like LHS data or record)' do
25
+ before do
26
+ class CustomStructure
27
+
28
+ def initialize(data)
29
+ @data = data
30
+ end
31
+
32
+ def as_json
33
+ @data.as_json
34
+ end
35
+
36
+ def to_json
37
+ as_json.to_json
38
+ end
39
+ end
40
+ end
41
+
42
+ let(:data) do
43
+ CustomStructure.new(id: '12345')
44
+ end
45
+
46
+ it 'compiles url from body params when body object respond_to(:as_json)' do
47
+ stub_request(:post, "http://datastore/places/12345")
48
+ .to_return(status: 200)
49
+ LHC.post('http://datastore/places/{id}', body: data)
50
+ end
51
+ end
23
52
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lhc
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.4.3
4
+ version: 9.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - https://github.com/local-ch/lhc/contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-10 00:00:00.000000000 Z
11
+ date: 2018-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport