Class: Decidim::PublicComponents

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

Overview

This query finds the published components for all public participatory spaces in the given organization. Can filter by manifest name.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(organization, manifest_name: nil) ⇒ PublicComponents

Returns a new instance of PublicComponents.


11
12
13
14
# File 'decidim-core/app/queries/decidim/public_components.rb', line 11

def initialize(organization, manifest_name: nil)
  @organization = organization
  @manifest_name = manifest_name
end

Class Method Details

.for(organization, manifest_name: nil) ⇒ Object


7
8
9
# File 'decidim-core/app/queries/decidim/public_components.rb', line 7

def self.for(organization, manifest_name: nil)
  new(organization, manifest_name: manifest_name).query
end

Instance Method Details

#queryObject


16
17
18
19
20
# File 'decidim-core/app/queries/decidim/public_components.rb', line 16

def query
  results = Decidim::Component.where(participatory_space: public_spaces).published
  results = results.where(manifest_name: manifest_name) if manifest_name.present?
  results
end