Class: Esplanade::Request::Doc

Inherits:
Object
  • Object
show all
Defined in:
lib/esplanade/request/doc.rb

Instance Method Summary collapse

Constructor Details

#initialize(main_documentation, raw) ⇒ Doc

Returns a new instance of Doc.



4
5
6
7
# File 'lib/esplanade/request/doc.rb', line 4

def initialize(main_documentation, raw)
  @main_documentation = main_documentation
  @raw = raw
end

Instance Method Details

#content_typeObject



34
35
36
# File 'lib/esplanade/request/doc.rb', line 34

def content_type
  @content_type ||= tomogram.content_type.to_s
end

#json_schemasObject



22
23
24
# File 'lib/esplanade/request/doc.rb', line 22

def json_schemas
  @json_schemas ||= tomogram.requests
end

#methodObject



26
27
28
# File 'lib/esplanade/request/doc.rb', line 26

def method
  @method ||= tomogram.method
end

#pathObject



30
31
32
# File 'lib/esplanade/request/doc.rb', line 30

def path
  @path ||= tomogram.path.to_s
end

#responsesObject



38
39
40
41
42
# File 'lib/esplanade/request/doc.rb', line 38

def responses
  @responses ||= tomogram.responses
rescue NotDocumented
  []
end

#tomogramObject

Raises:



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/esplanade/request/doc.rb', line 9

def tomogram
  raise PrefixNotMatch.new(**message) unless @main_documentation.prefix_match?(@raw.path)

  @tomogram = @main_documentation.find_request_with_content_type(
    method: @raw.method,
    path: @raw.path,
    content_type: @raw.content_type
  )
  raise NotDocumented.new(**message) if @tomogram.nil?

  @tomogram
end