Class: Scorpio::OpenAPI::OperationsScope
- Inherits:
-
Object
- Object
- Scorpio::OpenAPI::OperationsScope
- Includes:
- Enumerable
- Defined in:
- lib/scorpio/openapi/operations_scope.rb
Overview
OperationsScope is an Enumerable for a collection of Operations, and offers subscripting by operationId.
Instance Attribute Summary collapse
-
#openapi_document ⇒ Object
readonly
Returns the value of attribute openapi_document.
Instance Method Summary collapse
- #by_id(operationId) ⇒ Scorpio::OpenAPI::Operation?
-
#by_id!(operationId) ⇒ Scorpio::OpenAPI::Operation
(also: #[])
finds an operation with the given
operationId. - #each {|Scorpio::OpenAPI::Operation| ... } ⇒ Object
-
#initialize(enum) ⇒ OperationsScope
constructor
A new instance of OperationsScope.
- #reject(&block) ⇒ OperationsScope
- #select(&block) ⇒ OperationsScope
-
#tagged(tag) ⇒ OperationsScope
Operations with the indicated tag.
Constructor Details
#initialize(enum) ⇒ OperationsScope
Returns a new instance of OperationsScope.
9 10 11 12 13 14 |
# File 'lib/scorpio/openapi/operations_scope.rb', line 9 def initialize(enum) @enum = enum @operations_by_id = Hash.new do |h, operationId| h[operationId] = enum.detect { |operation| operation.operationId == operationId } end end |
Instance Attribute Details
#openapi_document ⇒ Object (readonly)
Returns the value of attribute openapi_document.
15 16 17 |
# File 'lib/scorpio/openapi/operations_scope.rb', line 15 def openapi_document @openapi_document end |
Instance Method Details
#by_id(operationId) ⇒ Scorpio::OpenAPI::Operation?
25 26 27 |
# File 'lib/scorpio/openapi/operations_scope.rb', line 25 def by_id(operationId) @operations_by_id[operationId] end |
#by_id!(operationId) ⇒ Scorpio::OpenAPI::Operation Also known as: []
finds an operation with the given operationId
33 34 35 |
# File 'lib/scorpio/openapi/operations_scope.rb', line 33 def by_id!(operationId) @operations_by_id[operationId] || raise(::KeyError, -"operationId not found: #{operationId.inspect}") end |
#each {|Scorpio::OpenAPI::Operation| ... } ⇒ Object
18 19 20 |
# File 'lib/scorpio/openapi/operations_scope.rb', line 18 def each(&block) @enum.each(&block) end |
#reject(&block) ⇒ OperationsScope
45 46 47 |
# File 'lib/scorpio/openapi/operations_scope.rb', line 45 def reject(&block) OperationsScope.new(@enum.reject(&block)) end |
#select(&block) ⇒ OperationsScope
40 41 42 |
# File 'lib/scorpio/openapi/operations_scope.rb', line 40 def select(&block) OperationsScope.new(@enum.select(&block)) end |
#tagged(tag) ⇒ OperationsScope
Operations with the indicated tag
52 53 54 55 |
# File 'lib/scorpio/openapi/operations_scope.rb', line 52 def tagged(tag) tag_name = tag.is_a?(OpenAPI::Tag) ? tag.name : tag select { |op| op.tagged?(tag_name) } end |