Class: BallotVote

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/ballot_vote.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new_for_ballot(ballot) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'app/models/ballot_vote.rb', line 12

def self.new_for_ballot(ballot)
  bv = BallotVote.new :ballot => ballot
  ballot.offices.each do |office|
    ov = bv.office_votes.build :office => office
    office.candidates.each do |candidate|
      ov.candidate_votes.build :candidate => candidate
    end
  end
  bv
end

Instance Method Details

#tampered?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'app/models/ballot_vote.rb', line 23

def tampered?
  !ballot || office_votes.any? { |office_vote| office_vote.tampered? ballot }
end