Sha256: afa10be53170e998d30f59f1754d91b12408e6715e6405663ffecd714e2a369c

Contents?: true

Size: 838 Bytes

Versions: 10

Compression:

Stored size: 838 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Core
    # 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
    class ParticipatorySpaceFinderBase < GraphQL::Function
      attr_reader :manifest

      def initialize(manifest:)
        @manifest = manifest
      end

      # lazy instantation of the class
      def model_class
        @model_class ||= manifest.model_class_name.constantize
      end

      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
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
decidim-core-0.23.6 app/functions/decidim/core/participatory_space_finder_base.rb
decidim-core-0.23.5 app/functions/decidim/core/participatory_space_finder_base.rb
decidim-core-0.23.4 app/functions/decidim/core/participatory_space_finder_base.rb
decidim-core-0.23.3 app/functions/decidim/core/participatory_space_finder_base.rb
decidim-core-0.23.2 app/functions/decidim/core/participatory_space_finder_base.rb
decidim-core-0.23.1 app/functions/decidim/core/participatory_space_finder_base.rb
decidim-core-0.23.1.rc1 app/functions/decidim/core/participatory_space_finder_base.rb
decidim-core-0.23.0 app/functions/decidim/core/participatory_space_finder_base.rb
decidim-core-0.22.0 app/functions/decidim/core/participatory_space_finder_base.rb
decidim-core-0.21.0 app/functions/decidim/core/participatory_space_finder_base.rb