lhc 10.0.1 → 10.0.2

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: a9d4825d86423a83e6d1bdd293e61871071b8d88e4b74d86e97236ffe96a7cb5
4
- data.tar.gz: 0b150f3793b6afcbf778bbcb1188a5e3dd02ab1727f96546c09c2363e5cf5dc6
3
+ metadata.gz: fcff9d45e512c5c1a8c76aaffb710eb73d5a5b03909e167e5a584fc4614a6d19
4
+ data.tar.gz: 366dd2f2b123018ca3d06d21d2e3eafd75923a292f363a54e1c8163f78753286
5
5
  SHA512:
6
- metadata.gz: b4ecc3fba3fbc4ce13394e16a3b8b5c82d3d6e0d0cbfc0dc83d57fc01c4afb2e7f8abbc1ba6ae272d8ad5fbf1a21f482786726d349fdfa9781de38c11d5fa9ef
7
- data.tar.gz: 8bbaedf6a7f7cfe7d195d69d457bc7fa238b9207149d1d0dcc56b55dafbf4aca291adeba3cfba166d000d68e8a67914cc8963c4f9d6864ff18933096cff79aa5
6
+ metadata.gz: 9f57d6a94e86a60ec2866aefdf15f472353e270e0a8df7f88bbbded053f2d84dd59e7e3ff9027b9f629aa7a355e905a407dc41c7727996c53b35c6e76ebc09dc
7
+ data.tar.gz: d94e275d67dad755be1a0ce290eca7ff7a1defeaadf30ea202d6659eca9a14d23e14fc220b8992d4087278e806f851b36b0be28aa7b71873b6266f4dde6658c3
data/lib/lhc/request.rb CHANGED
@@ -111,8 +111,8 @@ class LHC::Request
111
111
  def generate_url_from_template!
112
112
  endpoint = LHC::Endpoint.new(options[:url])
113
113
  params =
114
- if format && options[:body]&.length && options[:body].is_a?(Hash)
115
- options[:body].merge(options[:params] || {}).deep_symbolize_keys
114
+ if format && options[:body].present? && options[:body].respond_to?(:as_json) && options[:body].as_json.is_a?(Hash)
115
+ options[:body].as_json.merge(options[:params] || {}).deep_symbolize_keys
116
116
  else
117
117
  options[:params]
118
118
  end
data/lib/lhc/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module LHC
2
- VERSION ||= '10.0.1'
2
+ VERSION ||= '10.0.2'
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: 10.0.1
4
+ version: 10.0.2
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-11 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