Sha256: 39ac78eb5ac434bfcb59d92c2ba84c3f7cdfab14191fa903319c10592e2f4bf7
Contents?: true
Size: 853 Bytes
Versions: 19
Compression:
Stored size: 853 Bytes
Contents
# frozen_string_literal: true module Decidim module Elections module Votes # A class used to find the last vote casted by a voter in an election class LastVoteForVoter < Decidim::Query # 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 def self.for(election, voter_id) new(election, voter_id).query end def initialize(election, voter_id) @voter_id = voter_id @election = election end def query Decidim::Elections::Vote.where(election: @election, voter_id: @voter_id) .order("created_at") .last end end end end end
Version data entries
19 entries across 19 versions & 1 rubygems