Class: Docit::Operation
- Inherits:
-
Object
- Object
- Docit::Operation
- Defined in:
- lib/docit/operation.rb
Overview
Represents the documentation for a single controller action. Created by doc_for and stored in the Registry.
Instance Attribute Summary collapse
-
#_deprecated ⇒ Object
readonly
Returns the value of attribute _deprecated.
-
#_description ⇒ Object
readonly
Returns the value of attribute _description.
-
#_operation_id ⇒ Object
readonly
Returns the value of attribute _operation_id.
-
#_parameters ⇒ Object
readonly
Returns the value of attribute _parameters.
-
#_request_body ⇒ Object
readonly
Returns the value of attribute _request_body.
-
#_responses ⇒ Object
readonly
Returns the value of attribute _responses.
-
#_security ⇒ Object
readonly
Returns the value of attribute _security.
-
#_summary ⇒ Object
readonly
Returns the value of attribute _summary.
-
#_tags ⇒ Object
readonly
Returns the value of attribute _tags.
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
Instance Method Summary collapse
- #deprecated(value: true) ⇒ Object
- #description(text) ⇒ Object
-
#initialize(controller:, action:) ⇒ Operation
constructor
A new instance of Operation.
- #operation_id(text) ⇒ Object
- #parameter(name, location:, type: :string, required: false, description: nil, **opts) ⇒ Object
- #request_body(required: false, content_type: "application/json", &block) ⇒ Object
- #response(status, description = "", &block) ⇒ Object
- #security(scheme) ⇒ Object
- #summary(text) ⇒ Object
- #tags(*tags_list) ⇒ Object
Constructor Details
#initialize(controller:, action:) ⇒ Operation
Returns a new instance of Operation.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/docit/operation.rb', line 11 def initialize(controller:, action:) @controller = controller @action = action.to_s @_tags = [] @_responses = [] @_parameters = Builders::ParameterBuilder.new @_request_body = nil @_security = [] @_deprecated = false @_operation_id = nil end |
Instance Attribute Details
#_deprecated ⇒ Object (readonly)
Returns the value of attribute _deprecated.
7 8 9 |
# File 'lib/docit/operation.rb', line 7 def _deprecated @_deprecated end |
#_description ⇒ Object (readonly)
Returns the value of attribute _description.
7 8 9 |
# File 'lib/docit/operation.rb', line 7 def _description @_description end |
#_operation_id ⇒ Object (readonly)
Returns the value of attribute _operation_id.
7 8 9 |
# File 'lib/docit/operation.rb', line 7 def _operation_id @_operation_id end |
#_parameters ⇒ Object (readonly)
Returns the value of attribute _parameters.
7 8 9 |
# File 'lib/docit/operation.rb', line 7 def _parameters @_parameters end |
#_request_body ⇒ Object (readonly)
Returns the value of attribute _request_body.
7 8 9 |
# File 'lib/docit/operation.rb', line 7 def _request_body @_request_body end |
#_responses ⇒ Object (readonly)
Returns the value of attribute _responses.
7 8 9 |
# File 'lib/docit/operation.rb', line 7 def _responses @_responses end |
#_security ⇒ Object (readonly)
Returns the value of attribute _security.
7 8 9 |
# File 'lib/docit/operation.rb', line 7 def _security @_security end |
#_summary ⇒ Object (readonly)
Returns the value of attribute _summary.
7 8 9 |
# File 'lib/docit/operation.rb', line 7 def _summary @_summary end |
#_tags ⇒ Object (readonly)
Returns the value of attribute _tags.
7 8 9 |
# File 'lib/docit/operation.rb', line 7 def @_tags end |
#action ⇒ Object (readonly)
Returns the value of attribute action.
7 8 9 |
# File 'lib/docit/operation.rb', line 7 def action @action end |
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
7 8 9 |
# File 'lib/docit/operation.rb', line 7 def controller @controller end |
Instance Method Details
#deprecated(value: true) ⇒ Object
35 36 37 |
# File 'lib/docit/operation.rb', line 35 def deprecated(value: true) @_deprecated = value end |
#description(text) ⇒ Object
27 28 29 |
# File 'lib/docit/operation.rb', line 27 def description(text) @_description = text end |
#operation_id(text) ⇒ Object
39 40 41 |
# File 'lib/docit/operation.rb', line 39 def operation_id(text) @_operation_id = text end |
#parameter(name, location:, type: :string, required: false, description: nil, **opts) ⇒ Object
47 48 49 |
# File 'lib/docit/operation.rb', line 47 def parameter(name, location:, type: :string, required: false, description: nil, **opts) @_parameters.add(name, location: location, type: type, required: required, description: description, **opts) end |
#request_body(required: false, content_type: "application/json", &block) ⇒ Object
51 52 53 54 55 |
# File 'lib/docit/operation.rb', line 51 def request_body(required: false, content_type: "application/json", &block) builder = Builders::RequestBodyBuilder.new(required: required, content_type: content_type) builder.instance_eval(&block) if block_given? @_request_body = builder end |
#response(status, description = "", &block) ⇒ Object
57 58 59 60 61 |
# File 'lib/docit/operation.rb', line 57 def response(status, description = "", &block) builder = Builders::ResponseBuilder.new(status: status, description: description) builder.instance_eval(&block) if block_given? @_responses << builder end |
#security(scheme) ⇒ Object
43 44 45 |
# File 'lib/docit/operation.rb', line 43 def security(scheme) @_security << scheme end |
#summary(text) ⇒ Object
23 24 25 |
# File 'lib/docit/operation.rb', line 23 def summary(text) @_summary = text end |
#tags(*tags_list) ⇒ Object
31 32 33 |
# File 'lib/docit/operation.rb', line 31 def (*) @_tags = .flatten end |