Class: Decidim::Core::ParticipatorySpaceFinderBase

Inherits:
GraphQL::Function
  • Object
show all
Defined in:
app/functions/decidim/core/participatory_space_finder_base.rb

Overview

An abstract base class resolver for the GraphQL endpoint for a single participatory space Inherit from this class and add search arguments to create finder participatory classes as is shown in ParticipatorySpaceFinder

Direct Known Subclasses

ParticipatorySpaceFinder

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(manifest:) ⇒ ParticipatorySpaceFinderBase

Returns a new instance of ParticipatorySpaceFinderBase.



11
12
13
# File 'app/functions/decidim/core/participatory_space_finder_base.rb', line 11

def initialize(manifest:)
  @manifest = manifest
end

Instance Attribute Details

#manifestObject (readonly)

Returns the value of attribute manifest.



9
10
11
# File 'app/functions/decidim/core/participatory_space_finder_base.rb', line 9

def manifest
  @manifest
end

Instance Method Details

#call(_obj, args, ctx) ⇒ Object



20
21
22
23
24
25
26
# File 'app/functions/decidim/core/participatory_space_finder_base.rb', line 20

def call(_obj, args, ctx)
  query = { organization: ctx[:current_organization] }
  args.keys.each do |key|
    query[key] = args[key]
  end
  model_class.public_spaces.find_by(query)
end

#model_classObject

lazy instantation of the class



16
17
18
# File 'app/functions/decidim/core/participatory_space_finder_base.rb', line 16

def model_class
  @model_class ||= manifest.model_class_name.constantize
end