Class: Decidim::Votings::Votes::InPersonVoteForVoter

Inherits:
Query
  • Object
show all
Defined in:
decidim-elections/app/queries/decidim/votings/votes/in_person_vote_for_voter.rb

Overview

A class used to find a non-rejected in person vote registered for a voter in an election

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Query

#cached_query, #each, #eager?, #exists?, merge, #none?, #relation?, #|

Constructor Details

#initialize(election, voter_id) ⇒ InPersonVoteForVoter

Returns a new instance of InPersonVoteForVoter.



16
17
18
19
# File 'decidim-elections/app/queries/decidim/votings/votes/in_person_vote_for_voter.rb', line 16

def initialize(election, voter_id)
  @voter_id = voter_id
  @election = election
end

Class Method Details

.for(election, voter_id) ⇒ Object

Syntactic sugar to initialize the class and return the queried objects.

election - the election where the vote was casted voter_id - the identifier of the voter



12
13
14
# File 'decidim-elections/app/queries/decidim/votings/votes/in_person_vote_for_voter.rb', line 12

def self.for(election, voter_id)
  new(election, voter_id).query
end

Instance Method Details

#queryObject



21
22
23
# File 'decidim-elections/app/queries/decidim/votings/votes/in_person_vote_for_voter.rb', line 21

def query
  Decidim::Votings::InPersonVote.not_rejected.find_by(election: @election, voter_id: @voter_id)
end