Class: ZombieBattleground::Api::Responses::GetDecksResponse
- Inherits:
-
Object
- Object
- ZombieBattleground::Api::Responses::GetDecksResponse
- Includes:
- ActiveModel::Validations, ResponseHelper, ValidationHelper
- Defined in:
- lib/zombie_battleground/api/responses/get_decks_response.rb
Overview
Response validator for GetDecks
Instance Attribute Summary collapse
-
#decks ⇒ Array<ZombieBattleground::Api::Models::Deck>
readonly
the deck found for the page and limit.
-
#decks_count ⇒ Integer
readonly
the number of decks returned in the response.
-
#limit ⇒ Integer
readonly
the limit of results for the page.
-
#page ⇒ Integer
readonly
the page number of the results.
-
#remove_invalid ⇒ Boolean
flag to remove objects in response that are invalid during validation.
-
#total ⇒ Integer
readonly
the total number of results available.
Instance Method Summary collapse
-
#initialize(response) ⇒ ZombieBattleground::Api::GetDecksResponse
constructor
Creates a new GetDecksResponse.
Constructor Details
#initialize(response) ⇒ ZombieBattleground::Api::GetDecksResponse
Creates a new GetDecksResponse
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/zombie_battleground/api/responses/get_decks_response.rb', line 109 def initialize(response) handle_errors(response) JSON.parse(response.body).each do |key, value| if key == 'decks' # Keep the API response count, it will differ when invalid decks are stripped @decks_count = value.size instance_variable_set( "@#{key}".to_sym, value.map { |deck| ZombieBattleground::Api::Models::Deck.new(deck) } ) else instance_variable_set("@#{key}".to_sym, value) end end end |
Instance Attribute Details
#decks ⇒ Array<ZombieBattleground::Api::Models::Deck> (readonly)
the deck found for the page and limit
66 67 68 |
# File 'lib/zombie_battleground/api/responses/get_decks_response.rb', line 66 def decks @decks end |
#decks_count ⇒ Integer (readonly)
the number of decks returned in the response
78 79 80 |
# File 'lib/zombie_battleground/api/responses/get_decks_response.rb', line 78 def decks_count @decks_count end |
#limit ⇒ Integer (readonly)
the limit of results for the page
54 55 56 |
# File 'lib/zombie_battleground/api/responses/get_decks_response.rb', line 54 def limit @limit end |
#page ⇒ Integer (readonly)
the page number of the results
42 43 44 |
# File 'lib/zombie_battleground/api/responses/get_decks_response.rb', line 42 def page @page end |
#remove_invalid ⇒ Boolean
flag to remove objects in response that are invalid during validation
90 91 92 |
# File 'lib/zombie_battleground/api/responses/get_decks_response.rb', line 90 def remove_invalid @remove_invalid end |
#total ⇒ Integer (readonly)
the total number of results available
30 31 32 |
# File 'lib/zombie_battleground/api/responses/get_decks_response.rb', line 30 def total @total end |