class Esplanade::Request::Doc

Public Class Methods

new(main_documentation, raw) click to toggle source
# File lib/esplanade/request/doc.rb, line 4
def initialize(main_documentation, raw)
  @main_documentation = main_documentation
  @raw = raw
end

Public Instance Methods

content_type() click to toggle source
# File lib/esplanade/request/doc.rb, line 34
def content_type
  @content_type ||= tomogram.content_type.to_s
end
json_schemas() click to toggle source
# File lib/esplanade/request/doc.rb, line 22
def json_schemas
  @json_schemas ||= tomogram.requests
end
method() click to toggle source
# File lib/esplanade/request/doc.rb, line 26
def method
  @method ||= tomogram.method
end
path() click to toggle source
# File lib/esplanade/request/doc.rb, line 30
def path
  @path ||= tomogram.path.to_s
end
responses() click to toggle source
# File lib/esplanade/request/doc.rb, line 38
def responses
  @responses ||= tomogram.responses
rescue NotDocumented
  []
end
tomogram() click to toggle source
# 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

Private Instance Methods

message() click to toggle source
# File lib/esplanade/request/doc.rb, line 46
def message
  {
    method: @raw.method,
    path: @raw.path,
    raw_path: @raw.raw_path,
    content_type: @raw.content_type
  }
end