Class: RestClient::JsonResource
- Inherits:
-
Resource
- Object
- Resource
- RestClient::JsonResource
show all
- Defined in:
- lib/cangrejo/restclient/json_resource.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(_method, *_args, &_block) ⇒ Object
38
39
40
41
42
|
# File 'lib/cangrejo/restclient/json_resource.rb', line 38
def method_missing(_method, *_args, &_block)
if @state.is_a? Hash and @state.has_key? _method.to_s
@state[_method.to_s]
else super end
end
|
Instance Method Details
#delete(additional_headers = {}, &block) ⇒ Object
26
27
28
29
|
# File 'lib/cangrejo/restclient/json_resource.rb', line 26
def delete(={}, &block)
super (), &block
self
end
|
#get(additional_headers = {}, &block) ⇒ Object
7
8
9
10
11
12
|
# File 'lib/cangrejo/restclient/json_resource.rb', line 7
def get(={}, &block)
['Accept'] = 'json'
r = super , &block
@state = JSON.parse r
self
end
|
#post(payload, additional_headers = {}, &block) ⇒ Object
14
15
16
17
18
|
# File 'lib/cangrejo/restclient/json_resource.rb', line 14
def post(payload, ={}, &block)
r = super payload.to_json, (), &block
@state = JSON.parse r
self
end
|
#put(payload, additional_headers = {}, &block) ⇒ Object
20
21
22
23
24
|
# File 'lib/cangrejo/restclient/json_resource.rb', line 20
def put(payload, ={}, &block)
r = super payload.to_json, (), &block
@state = JSON.parse r
self
end
|