Module: Decidim::Core::ParticipatorySpaceInterface

Includes:
Api::Types::BaseInterface
Defined in:
decidim-core/lib/decidim/api/interfaces/participatory_space_interface.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.resolve_type(obj, _ctx) ⇒ Object


43
44
45
# File 'decidim-core/lib/decidim/api/interfaces/participatory_space_interface.rb', line 43

def self.resolve_type(obj, _ctx)
  obj.manifest.query_type.constantize
end

Instance Method Details

#components(filter: {}, order: {}) ⇒ Object


25
26
27
# File 'decidim-core/lib/decidim/api/interfaces/participatory_space_interface.rb', line 25

def components(filter: {}, order: {})
  ComponentList.new.call(object, { filter: filter, order: order }, context)
end

#statsObject


31
32
33
34
35
36
37
38
39
40
41
# File 'decidim-core/lib/decidim/api/interfaces/participatory_space_interface.rb', line 31

def stats
  return if object.respond_to?(:show_statistics) && !object.show_statistics

  published_components = Component.where(participatory_space: object).published

  stats = Decidim.component_manifests.map do |component_manifest|
    component_manifest.stats.with_context(published_components).map { |name, data| [name, data] }.flatten
  end

  stats.reject(&:empty?)
end

#typeObject


16
17
18
# File 'decidim-core/lib/decidim/api/interfaces/participatory_space_interface.rb', line 16

def type
  object.class.name
end