Class: Swagger::V2::Path

Inherits:
DefinitionSection show all
Extended by:
Forwardable
Defined in:
lib/swagger/v2/path.rb

Constant Summary collapse

VERBS =
[:get, :put, :post, :delete, :options, :head, :patch]

Instance Attribute Summary

Attributes inherited from DefinitionSection

#parent

Instance Method Summary collapse

Methods inherited from DefinitionSection

required_section, section

Methods included from Attachable

#attach_parent, #attach_to_children, #root

Constructor Details

#initialize(hash) ⇒ Path

Returns a new instance of Path.



17
18
19
20
# File 'lib/swagger/v2/path.rb', line 17

def initialize(hash)
  hash[:parameters] ||= []
  super
end

Instance Method Details

#operationsObject



22
23
24
25
26
27
# File 'lib/swagger/v2/path.rb', line 22

def operations
  VERBS.each_with_object({}) do | v, h |
    operation = send v
    h[v] = operation if operation
  end
end

#pathObject



33
34
35
# File 'lib/swagger/v2/path.rb', line 33

def path
  parent.paths.key self
end

#uri_templateObject



29
30
31
# File 'lib/swagger/v2/path.rb', line 29

def uri_template
  "#{parent.host}#{parent.base_path}#{path}"
end