Class: Mountapi::Route::Responses

Inherits:
Object
  • Object
show all
Defined in:
lib/mountapi/route/responses.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(responses) ⇒ Responses



10
11
12
# File 'lib/mountapi/route/responses.rb', line 10

def initialize(responses)
  @responses = responses
end

Class Method Details

.build(responses = []) ⇒ Object



6
7
8
# File 'lib/mountapi/route/responses.rb', line 6

def self.build(responses = [])
  new(responses.map { |r| Mountapi::Route::Response.build(*r) })
end

Instance Method Details

#[](status) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/mountapi/route/responses.rb', line 14

def [](status)
  response = @responses.find { |resp| resp.match?(status) }

  if response
    response.schema
  else
    raise Error::MissingResponseStatus.new("No schema found for response status code #{status}")
  end
end