Class: Decidim::Votings::Admin::BallotStyleByVotingCode

Inherits:
Rectify::Query
  • Object
show all
Defined in:
decidim-elections/app/queries/decidim/votings/admin/ballot_style_by_voting_code.rb

Overview

A class used to find trustees by participatory space.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(voting, code) ⇒ BallotStyleByVotingCode

Initializes the class.


17
18
19
20
# File 'decidim-elections/app/queries/decidim/votings/admin/ballot_style_by_voting_code.rb', line 17

def initialize(voting, code)
  @voting = voting
  @code = code
end

Class Method Details

.for(voting, code) ⇒ Object

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

voting - the voting of the Ballot Style code - the code of the Ballot Style


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

def self.for(voting, code)
  new(voting, code).query
end

Instance Method Details

#queryObject

Gets the ballot style with the specified code in this voting


23
24
25
26
27
# File 'decidim-elections/app/queries/decidim/votings/admin/ballot_style_by_voting_code.rb', line 23

def query
  Decidim::Votings::BallotStyle
    .where(voting: @voting)
    .find_by(code: @code)
end