Class: Decidim::Assemblies::FilteredAssemblies

Inherits:
Rectify::Query
  • Object
show all
Defined in:
decidim-assemblies/app/queries/decidim/assemblies/filtered_assemblies.rb

Overview

This query filters assemblies by type.

Instance Method Summary collapse

Constructor Details

#initialize(filter) ⇒ FilteredAssemblies

Returns a new instance of FilteredAssemblies.


7
8
9
# File 'decidim-assemblies/app/queries/decidim/assemblies/filtered_assemblies.rb', line 7

def initialize(filter)
  @filter = filter
end

Instance Method Details

#assembliesObject


11
12
13
# File 'decidim-assemblies/app/queries/decidim/assemblies/filtered_assemblies.rb', line 11

def assemblies
  Decidim::Assembly
end

#queryObject


15
16
17
18
19
# File 'decidim-assemblies/app/queries/decidim/assemblies/filtered_assemblies.rb', line 15

def query
  return assemblies.all if @filter.blank?

  assemblies.where(decidim_assemblies_type_id: @filter)
end