Class: Decidim::Core::ParticipatorySpaceFinderBase
- Inherits:
-
Object
- Object
- Decidim::Core::ParticipatorySpaceFinderBase
- Defined in:
- decidim-core/lib/decidim/api/functions/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
Instance Attribute Summary collapse
-
#manifest ⇒ Object
readonly
Returns the value of attribute manifest.
Instance Method Summary collapse
- #call(_obj, args, ctx) ⇒ Object
-
#initialize(manifest:) ⇒ ParticipatorySpaceFinderBase
constructor
A new instance of ParticipatorySpaceFinderBase.
-
#model_class ⇒ Object
lazy instantiation of the class.
Constructor Details
#initialize(manifest:) ⇒ ParticipatorySpaceFinderBase
Returns a new instance of ParticipatorySpaceFinderBase.
11 12 13 |
# File 'decidim-core/lib/decidim/api/functions/participatory_space_finder_base.rb', line 11 def initialize(manifest:) @manifest = manifest end |
Instance Attribute Details
#manifest ⇒ Object (readonly)
Returns the value of attribute manifest.
9 10 11 |
# File 'decidim-core/lib/decidim/api/functions/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 27 28 29 30 31 32 33 34 35 36 |
# File 'decidim-core/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 @query = if ctx[:current_user]&.admin? model_class elsif model_class.respond_to?(:visible_for) model_class.visible_for(ctx[:current_user]) else model_class.public_spaces end @query.find_by(query) end |
#model_class ⇒ Object
lazy instantiation of the class
16 17 18 |
# File 'decidim-core/lib/decidim/api/functions/participatory_space_finder_base.rb', line 16 def model_class @model_class ||= manifest.model_class_name.constantize end |