Class: PactBroker::Api::Resources::Matrix
- Inherits:
-
BaseResource
- Object
- BaseResource
- PactBroker::Api::Resources::Matrix
- Defined in:
- lib/pact_broker/api/resources/matrix.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#selectors ⇒ Object
readonly
Returns the value of attribute selectors.
Instance Method Summary collapse
- #allowed_methods ⇒ Object
- #content_types_provided ⇒ Object
-
#initialize ⇒ Matrix
constructor
A new instance of Matrix.
- #malformed_request? ⇒ Boolean
- #results ⇒ Object
- #to_json ⇒ Object
- #to_text ⇒ Object
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 (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/pact_broker/api/resources/matrix.rb', line 10 def @options end |
#selectors ⇒ Object (readonly)
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 |
#malformed_request? ⇒ Boolean
28 29 30 31 32 33 34 35 36 |
# File 'lib/pact_broker/api/resources/matrix.rb', line 28 def malformed_request? = matrix_service.validate_selectors(selectors) if .any? true else false end end |
#results ⇒ Object
46 47 48 |
# File 'lib/pact_broker/api/resources/matrix.rb', line 46 def results @results ||= matrix_service.find(selectors, ) end |
#to_json ⇒ Object
38 39 40 |
# File 'lib/pact_broker/api/resources/matrix.rb', line 38 def to_json PactBroker::Api::Decorators::MatrixDecorator.new(results).to_json() end |
#to_text ⇒ Object
42 43 44 |
# File 'lib/pact_broker/api/resources/matrix.rb', line 42 def to_text PactBroker::Api::Decorators::MatrixTextDecorator.new(results).to_text() end |