class ZombieBattleground::Api::Responses::GetMatchResponse

Response validator for GetMatch

Attributes

match[R]

@!attribute [r] match the match

@return [ZombieBattleground::Api::Models::Match]

@example

response.match #=> ZombieBattleground::Api::Models::Match

@api public

Public Class Methods

new(response) click to toggle source

Creates a new GetMatchResponse

@param response [Faraday::Response] Faraday response from endpoint

@return [ZombieBattleground::Api::GetMatchResponse]

@example

response = ZombieBattleground::Api::GetMatchResponse.new(faraday_response)
# => ZombieBattleground::Api::GetMatchResponse

@api public

# File lib/zombie_battleground/api/responses/get_match_response.rb, line 46
def initialize(response)
  handle_errors(response)

  @match = ZombieBattleground::Api::Models::Match.new(JSON.parse(response.body))
end

Private Instance Methods

match_is_a_match() click to toggle source

Validator for match attribute

@return [void]

@api private

# File lib/zombie_battleground/api/responses/get_match_response.rb, line 60
def match_is_a_match
  return if @match.is_a?(ZombieBattleground::Api::Models::Match) &&
            @match.valid? &&
            @match.errors.size.zero?

  errors.add(:match, 'match must be a Match')
end