Class: PactBroker::Api::Resources::Matrix
- Inherits:
-
BaseResource
- Object
- BaseResource
- PactBroker::Api::Resources::Matrix
show all
- Defined in:
- lib/pact_broker/api/resources/matrix.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ Matrix
Returns a new instance of Matrix.
12
13
14
15
|
# File 'lib/pact_broker/api/resources/matrix.rb', line 12
def initialize
super
@selectors, @options = PactBroker::Matrix::ParseQuery.call(request.uri.query)
end
|
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
10
11
12
|
# File 'lib/pact_broker/api/resources/matrix.rb', line 10
def options
@options
end
|
#selectors ⇒ Object
Returns the value of attribute selectors.
10
11
12
|
# File 'lib/pact_broker/api/resources/matrix.rb', line 10
def selectors
@selectors
end
|
Instance Method Details
#allowed_methods ⇒ Object
24
25
26
|
# File 'lib/pact_broker/api/resources/matrix.rb', line 24
def allowed_methods
["GET", "OPTIONS"]
end
|
#content_types_provided ⇒ Object
17
18
19
20
21
22
|
# File 'lib/pact_broker/api/resources/matrix.rb', line 17
def content_types_provided
[
["application/hal+json", :to_json],
["text/plain", :to_text]
]
end
|
28
29
30
31
32
33
34
35
36
|
# File 'lib/pact_broker/api/resources/matrix.rb', line 28
def malformed_request?
error_messages = matrix_service.validate_selectors(selectors)
if error_messages.any?
set_json_validation_error_messages error_messages
true
else
false
end
end
|
#policy_name ⇒ Object
46
47
48
|
# File 'lib/pact_broker/api/resources/matrix.rb', line 46
def policy_name
:'matrix::matrix'
end
|
#results ⇒ Object
50
51
52
|
# File 'lib/pact_broker/api/resources/matrix.rb', line 50
def results
@results ||= matrix_service.find(selectors, options)
end
|
#to_json ⇒ Object
38
39
40
|
# File 'lib/pact_broker/api/resources/matrix.rb', line 38
def to_json
decorator_class(:matrix_decorator).new(results).to_json(decorator_options)
end
|
#to_text ⇒ Object
42
43
44
|
# File 'lib/pact_broker/api/resources/matrix.rb', line 42
def to_text
decorator_class(:matrix_text_decorator).new(results).to_text(decorator_options)
end
|