class Decidim::Core::ParticipatorySpaceFinderBase

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

Attributes

manifest[R]

Public Class Methods

new(manifest:) click to toggle source
# File lib/decidim/api/functions/participatory_space_finder_base.rb, line 11
def initialize(manifest:)
  @manifest = manifest
end

Public Instance Methods

call(_obj, args, ctx) click to toggle source
# File lib/decidim/api/functions/participatory_space_finder_base.rb, line 20
def call(_obj, args, ctx)
  query = { organization: ctx[:current_organization] }
  args.compact.keys.each do |key|
    query[key] = args[key]
  end
  model_class.public_spaces.find_by(query)
end
model_class() click to toggle source

lazy instantation of the class

# File lib/decidim/api/functions/participatory_space_finder_base.rb, line 16
def model_class
  @model_class ||= manifest.model_class_name.constantize
end