rocking_chair 0.2.2 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/rocking_chair/http_adapter.rb +31 -7
  2. metadata +3 -3
@@ -4,7 +4,7 @@ module RockingChair
4
4
  def http_adapter
5
5
  unless @_restclient
6
6
  @_restclient = Object.new
7
- @_restclient.extend(RestClientAdapter::API)
7
+ @_restclient.extend(RestAPI)
8
8
  end
9
9
 
10
10
  if RockingChair.enabled?
@@ -15,27 +15,51 @@ module RockingChair
15
15
  end
16
16
 
17
17
  def get(uri, headers=nil)
18
- JSON.parse(http_adapter.get(uri, headers))
18
+ result = http_adapter.get(uri)
19
+ if result.is_a?(Hash)
20
+ result
21
+ else
22
+ JSON.parse(result)
23
+ end
19
24
  end
20
25
 
21
26
  def post(uri, payload, headers=nil)
22
- JSON.parse(http_adapter.post(uri, payload, headers))
27
+ result = http_adapter.post(uri, payload)
28
+ if result.is_a?(Hash)
29
+ result
30
+ else
31
+ JSON.parse(result)
32
+ end
23
33
  end
24
34
 
25
35
  def put(uri, payload=nil, headers=nil)
26
- JSON.parse(http_adapter.put(uri, payload, headers))
36
+ result = http_adapter.put(uri, payload)
37
+ if result.is_a?(Hash)
38
+ result
39
+ else
40
+ JSON.parse(result)
41
+ end
27
42
  end
28
43
 
29
44
  def delete(uri, headers=nil)
30
- JSON.parse(http_adapter.delete(uri, headers))
45
+ result = http_adapter.delete(uri)
46
+ if result.is_a?(Hash)
47
+ result
48
+ else
49
+ JSON.parse(result)
50
+ end
31
51
  end
32
52
 
33
53
  def copy(uri, destination)
34
- JSON.parse(http_adapter.copy(uri, default_headers.merge('Destination' => destination)))
54
+ result = http_adapter.copy(uri, default_headers.merge('Destination' => destination))
55
+ if result.is_a?(Hash)
56
+ result
57
+ else
58
+ JSON.parse(result)
59
+ end
35
60
  end
36
61
 
37
62
  end
38
63
  end
39
64
 
40
- #::RestAPI.extend(RockingChair::HttpAdapter)
41
65
  CouchRest.extend(RockingChair::HttpAdapter)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rocking_chair
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 2
10
- version: 0.2.2
9
+ - 4
10
+ version: 0.2.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jonathan Weiss