Class: Barker::Api::Response::Candidate

Inherits:
Base
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/barker/api/response/candidate.rb

Instance Method Summary collapse

Methods inherited from Base

#error?, #ok?

Instance Method Details

#jokersObject



9
10
11
# File 'lib/barker/api/response/candidate.rb', line 9

def jokers
  candidate.jokers.map {|candidate_joker| Response::CandidateJoker.new(:candidate_joker => candidate_joker)}
end

#to_hashObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/barker/api/response/candidate.rb', line 13

def to_hash
  {
    'id'           => id,
    'candidate_id' => candidate_id,
    'locale'       => locale,
    'jokers'       => jokers? && jokers.map(&:to_hash) || [],
    'joker_ids'    => jokers? && jokers.map(&:joker_id) || [],
    'joined_at'    => to_i(joined_at),
    'leaved_at'    => to_i(leaved_at),
    'aborted_at'   => to_i(aborted_at),
    'joined?'      => joined?, 
    'leaved?'      => leaved?,
    'aborted?'     => aborted?
  }
end