Class: Swaggard::Swagger::Path
- Inherits:
-
Object
- Object
- Swaggard::Swagger::Path
- Defined in:
- lib/swaggard/swagger/path.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #add_operation(operation) ⇒ Object
- #ignore_put_if_patch! ⇒ Object
-
#initialize(path) ⇒ Path
constructor
A new instance of Path.
- #to_doc ⇒ Object
Constructor Details
#initialize(path) ⇒ Path
Returns a new instance of Path.
8 9 10 11 |
# File 'lib/swaggard/swagger/path.rb', line 8 def initialize(path) @path = path @operations = {} end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/swaggard/swagger/path.rb', line 6 def path @path end |
Instance Method Details
#add_operation(operation) ⇒ Object
13 14 15 |
# File 'lib/swaggard/swagger/path.rb', line 13 def add_operation(operation) @operations[operation.http_method.downcase] = operation end |
#ignore_put_if_patch! ⇒ Object
17 18 19 |
# File 'lib/swaggard/swagger/path.rb', line 17 def ignore_put_if_patch! @operations.delete('put') if @operations.key?('patch') end |
#to_doc ⇒ Object
21 22 23 |
# File 'lib/swaggard/swagger/path.rb', line 21 def to_doc Hash[@operations.map { |http_method, operation| [http_method, operation.to_doc] }] end |