Class: Pact::Request::Base
- Inherits:
-
Object
- Object
- Pact::Request::Base
show all
- Includes:
- SymbolizeKeys
- Defined in:
- lib/pact/shared/request.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
included, #symbolize_keys
Constructor Details
#initialize(method, path, headers, body, query) ⇒ Base
12
13
14
15
16
17
18
|
# File 'lib/pact/shared/request.rb', line 12
def initialize(method, path, , body, query)
@method = method.to_s
@path = path
= Hash === ? .new() :
@body = body
set_query(query)
end
|
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
10
11
12
|
# File 'lib/pact/shared/request.rb', line 10
def body
@body
end
|
Returns the value of attribute headers.
10
11
12
|
# File 'lib/pact/shared/request.rb', line 10
def
end
|
#method ⇒ Object
Returns the value of attribute method.
10
11
12
|
# File 'lib/pact/shared/request.rb', line 10
def method
@method
end
|
#options ⇒ Object
Returns the value of attribute options.
10
11
12
|
# File 'lib/pact/shared/request.rb', line 10
def options
@options
end
|
#path ⇒ Object
Returns the value of attribute path.
10
11
12
|
# File 'lib/pact/shared/request.rb', line 10
def path
@path
end
|
#query ⇒ Object
Returns the value of attribute query.
10
11
12
|
# File 'lib/pact/shared/request.rb', line 10
def query
@query
end
|
Instance Method Details
#content_type ⇒ Object
39
40
41
42
|
# File 'lib/pact/shared/request.rb', line 39
def content_type
return nil unless specified?(:headers) && ['Content-Type']
Pact::Reification.from_term(['Content-Type'])
end
|
#content_type?(content_type) ⇒ Boolean
44
45
46
|
# File 'lib/pact/shared/request.rb', line 44
def content_type? content_type
self.content_type == content_type
end
|
#full_path ⇒ Object
35
36
37
|
# File 'lib/pact/shared/request.rb', line 35
def full_path
display_path + display_query
end
|
#method_and_path ⇒ Object
31
32
33
|
# File 'lib/pact/shared/request.rb', line 31
def method_and_path
"#{method.upcase} #{full_path}"
end
|
#modifies_resource? ⇒ Boolean
48
49
50
|
# File 'lib/pact/shared/request.rb', line 48
def modifies_resource?
http_method_modifies_resource? && body_specified?
end
|
#specified?(key) ⇒ Boolean
52
53
54
|
# File 'lib/pact/shared/request.rb', line 52
def specified? key
!is_unspecified?(self.send(key))
end
|
#to_hash ⇒ Object
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/pact/shared/request.rb', line 20
def to_hash
hash = {
method: method,
path: path,
}
hash[:query] = query if specified?(:query)
hash[:headers] = if specified?(:headers)
hash[:body] = body if specified?(:body)
hash
end
|