Class: Decidim::Core::ParticipatorySpaceListBase
- Inherits:
-
GraphQL::Function
- Object
- GraphQL::Function
- Decidim::Core::ParticipatorySpaceListBase
- Includes:
- NeedsApiFilterAndOrder
- Defined in:
- app/functions/decidim/core/participatory_space_list_base.rb
Overview
An abstract base class resolver for the GraphQL endpoint for listing participatory spaces Inherit from this class and add search arguments to create list-finders participatory classes as is shown in ParticipatorySpaceList + info: github.com/rmosolgo/graphql-ruby/blob/v1.6.8/guides/fields/function.md
Direct Known Subclasses
Instance Attribute Summary collapse
-
#manifest ⇒ Object
readonly
Returns the value of attribute manifest.
Instance Method Summary collapse
- #call(_obj, args, ctx) ⇒ Object
-
#initialize(manifest:) ⇒ ParticipatorySpaceListBase
constructor
A new instance of ParticipatorySpaceListBase.
-
#model_class ⇒ Object
lazy instantation of the class.
Methods included from NeedsApiFilterAndOrder
#add_filter_keys, #add_order_keys
Constructor Details
#initialize(manifest:) ⇒ ParticipatorySpaceListBase
Returns a new instance of ParticipatorySpaceListBase.
14 15 16 |
# File 'app/functions/decidim/core/participatory_space_list_base.rb', line 14 def initialize(manifest:) @manifest = manifest end |
Instance Attribute Details
#manifest ⇒ Object (readonly)
Returns the value of attribute manifest.
12 13 14 |
# File 'app/functions/decidim/core/participatory_space_list_base.rb', line 12 def manifest @manifest end |
Instance Method Details
#call(_obj, args, ctx) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'app/functions/decidim/core/participatory_space_list_base.rb', line 23 def call(_obj, args, ctx) @query = model_class.public_spaces.where( organization: ctx[:current_organization] ) add_filter_keys(args[:filter]) add_order_keys(args[:order].to_h) @query end |
#model_class ⇒ Object
lazy instantation of the class
19 20 21 |
# File 'app/functions/decidim/core/participatory_space_list_base.rb', line 19 def model_class @model_class ||= manifest.model_class_name.constantize end |