class ZombieBattleground::Api::Responses::GetCardResponse

Response validator for GetCard

Attributes

card[R]

@!attribute [r] card the card

@return [ZombieBattleground::Api::Deck]

@example

response.card #=> ZombieBattleground::Api::Deck

@api public

Public Class Methods

new(response) click to toggle source

Creates a new GetCardResponse

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

@return [ZombieBattleground::Api::GetCardResponse]

@example

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

@api public

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

  @card = ZombieBattleground::Api::Models::Card.new(JSON.parse(response.body))
end

Private Instance Methods

card_is_a_card() click to toggle source

Validator for card attribute

@return [void]

@api private

# File lib/zombie_battleground/api/responses/get_card_response.rb, line 62
def card_is_a_card
  return if @card.is_a?(ZombieBattleground::Api::Models::Card) &&
            @card.valid? &&
            @card.errors.size.zero?

  errors.add(:card, 'card must be a Card')
end