Class: OasRails::Spec::Paths

Inherits:
Object
  • Object
show all
Includes:
Specable
Defined in:
lib/oas_rails/spec/paths.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Specable

#as_json, #oas_fields

Constructor Details

#initialize(specification) ⇒ Paths

Returns a new instance of Paths.



8
9
10
11
# File 'lib/oas_rails/spec/paths.rb', line 8

def initialize(specification)
  @specification = specification
  @path_items = {}
end

Instance Attribute Details

#path_itemsObject

Returns the value of attribute path_items.



6
7
8
# File 'lib/oas_rails/spec/paths.rb', line 6

def path_items
  @path_items
end

Instance Method Details

#add_path(path) ⇒ Object



13
14
15
# File 'lib/oas_rails/spec/paths.rb', line 13

def add_path(path)
  @path_items[path] = Builders::PathItemBuilder.new(@specification).from_path(path).build
end

#to_specObject



17
18
19
20
21
22
23
# File 'lib/oas_rails/spec/paths.rb', line 17

def to_spec
  paths_hash = {}
  @path_items.each do |path, path_object|
    paths_hash[path] = path_object.to_spec
  end
  paths_hash
end