class ZombieBattleground::Api::Responses::GetDeckResponse

Response validator for GetDeck

Attributes

deck[R]

@!attribute [r] deck the deck

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

@example

response.deck #=> ZombieBattleground::Api::Models::Deck

@api public

Public Class Methods

new(response) click to toggle source

Creates a new GetDeckResponse

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

@return [ZombieBattleground::Api::GetDeckResponse]

@example

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

@api public

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

  @deck = ZombieBattleground::Api::Models::Deck.new(JSON.parse(response.body))
end

Private Instance Methods

deck_is_a_deck() click to toggle source

Validator for deck attribute

@return [void]

@api private

# File lib/zombie_battleground/api/responses/get_deck_response.rb, line 60
def deck_is_a_deck
  return if @deck.is_a?(ZombieBattleground::Api::Models::Deck) &&
            @deck.valid? &&
            @deck.errors.size.zero?

  errors.add(:deck, 'deck must be a Deck')
end