Class: Alchemrest::Request
- Inherits:
-
Object
- Object
- Alchemrest::Request
show all
- Defined in:
- lib/alchemrest/request.rb,
lib/alchemrest/request/returns.rb,
lib/alchemrest/request/endpoint.rb
Defined Under Namespace
Classes: Endpoint, Returns
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.disable_response_capture ⇒ Object
24
25
26
|
# File 'lib/alchemrest/request.rb', line 24
def self.disable_response_capture
define_method(:response_capture_enabled) { false }
end
|
.enable_response_capture ⇒ Object
20
21
22
|
# File 'lib/alchemrest/request.rb', line 20
def self.enable_response_capture
define_method(:response_capture_enabled) { true }
end
|
.endpoint(http_method, template, &block) ⇒ Object
14
15
16
17
18
|
# File 'lib/alchemrest/request.rb', line 14
def self.endpoint(http_method, template, &block)
builder_block = block
endpoint_definition = EndpointDefinition.new(template:, http_method: http_method.to_s, builder_block:)
include Endpoint.new(endpoint_definition)
end
|
.returns(domain_type, path_to_payload: nil, allow_empty_response: false) ⇒ Object
10
11
12
|
# File 'lib/alchemrest/request.rb', line 10
def self.returns(domain_type, path_to_payload: nil, allow_empty_response: false)
include Returns.new(domain_type, path_to_payload, allow_empty_response)
end
|
Instance Method Details
#body ⇒ Object
44
45
46
|
# File 'lib/alchemrest/request.rb', line 44
def body
nil
end
|
36
37
38
|
# File 'lib/alchemrest/request.rb', line 36
def
DEFAULT_HEADERS
end
|
40
41
42
|
# File 'lib/alchemrest/request.rb', line 40
def
{}
end
|
#http_method ⇒ Object
32
33
34
|
# File 'lib/alchemrest/request.rb', line 32
def http_method
raise NotImplementedError, 'This is an abstract base method. Implement in your subclass.'
end
|
#identifier ⇒ Object
70
71
72
|
# File 'lib/alchemrest/request.rb', line 70
def identifier
"#{http_method.upcase} #{path}"
end
|
#path ⇒ Object
28
29
30
|
# File 'lib/alchemrest/request.rb', line 28
def path
raise NotImplementedError, 'This is an abstract base method. Implement in your subclass.'
end
|
#response_capture_enabled ⇒ Object
61
62
63
|
# File 'lib/alchemrest/request.rb', line 61
def response_capture_enabled
true
end
|
65
66
67
68
|
# File 'lib/alchemrest/request.rb', line 65
def transform_response(response)
capture!(response:)
response_transformer.call(response)
end
|