Class: Decidim::Votings::Admin::PollingOfficersJoinPollingStationsAndUser

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

Overview

A class join the polling officers with their respective polling stations and users.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Query

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

Constructor Details

#initialize(polling_officers) ⇒ PollingOfficersJoinPollingStationsAndUser

Initializes the class.

polling_officers - the collection of polling officers



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

def initialize(polling_officers)
  @polling_officers = polling_officers
end

Class Method Details

.for(polling_officers) ⇒ Object

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

polling_officers - the collection of polling officers



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

def self.for(polling_officers)
  new(polling_officers).query
end

Instance Method Details

#queryObject

Finds joins the polling officers with their associated polling stations and users.

Returns an ActiveRecord::Relation.



25
26
27
28
29
30
# File 'decidim-elections/app/queries/decidim/votings/admin/polling_officers_join_polling_stations_and_user.rb', line 25

def query
  Decidim::Query.merge(
    PollingOfficersJoinPollingStations.new(@polling_officers),
    PollingOfficersJoinUser.new(@polling_officers)
  ).query
end