Class: Swaggard::Swagger::Path

Inherits:
Object
  • Object
show all
Defined in:
lib/swaggard/swagger/path.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#pathObject (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_docObject



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