Class: Decidim::ParticipatorySpaceManifest
- Inherits:
 - 
      Object
      
        
- Object
 - Decidim::ParticipatorySpaceManifest
 
 
- Includes:
 - ActiveModel::Model, AttributeObject::Model
 
- Defined in:
 - lib/decidim/participatory_space_manifest.rb
 
Overview
This class handles all the logic associated to configuring a participatory space, the highest level object of Decidim.
It is normally not used directly but through the API exposed through ‘Decidim.register_participatory_space`.
Constant Summary
Constants included from AttributeObject::TypeMap
AttributeObject::TypeMap::Boolean, AttributeObject::TypeMap::Decimal
Instance Method Summary collapse
- 
  
    
      #context(name = :public, &block)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
A context used to set the layout and behavior of a participatory space.
 - 
  
    
      #export_manifests  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Pubic: Returns a collection of previously registered export manifests for this space.
 - 
  
    
      #exports(name, &block)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Public: Registers an export artifact with a name and its properties defined in ‘Decidim::Exporters::ExportManifest`.
 - #invoke_on_destroy_account(user) ⇒ Object
 - 
  
    
      #participatory_spaces(&block)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Public: A block that retrieves all the participatory spaces for the manifest.
 - 
  
    
      #permissions_class  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Public: Finds the permission class from its name, using the ‘permissions_class_name` attribute.
 - 
  
    
      #register_on_destroy_account(&block)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
The block is a callback that will be invoked with the destroyed ‘user` as argument.
 - 
  
    
      #register_resource(name)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Public: Registers a resource.
 - 
  
    
      #register_stat(name, options = {})  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Public: Registers a stat inside a participatory_space manifest.
 - 
  
    
      #route_name  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
The name of the named Rails route to create the url to the resource.
 - 
  
    
      #seed!  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Public: Creates the seeds for this components in order to populate the database.
 - 
  
    
      #seeds(&block)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Public: A block that gets called when seeding for this component takes place.
 - 
  
    
      #stats  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Public: Stores an instance of StatsRegistry.
 
Methods included from AttributeObject::Model
#[], #[]=, #attributes, #attributes_with_values, #initialize, #to_h
Instance Method Details
#context(name = :public, &block) ⇒ Object
A context used to set the layout and behavior of a participatory space. Full documentation can be found looking at the ‘ParticipatorySpaceContextManifest` class.
Example:
context(:public) do |context|
  context.layout "layouts/decidim/some_layout"
end
context(:public).layout
# => "layouts/decidim/some_layout"
Returns Nothing.
      77 78 79 80 81 82 83 84 85 86 87 88  | 
    
      # File 'lib/decidim/participatory_space_manifest.rb', line 77 def context(name = :public, &block) name = name.to_sym @contexts ||= {} if block context = ParticipatorySpaceContextManifest.new context.instance_eval(&block) @contexts[name] = context end @contexts.fetch(name) end  | 
  
#export_manifests ⇒ Object
Pubic: Returns a collection of previously registered export manifests for this space.
Returns an Array of <Decidim::Exporters::ExportManifest>.
      186 187 188 189 190 191 192  | 
    
      # File 'lib/decidim/participatory_space_manifest.rb', line 186 def export_manifests @export_manifests ||= Array(@exports).map do |(name, block)| Decidim::Exporters::ExportManifest.new(name, self).tap do |manifest| block.call(manifest) end end end  | 
  
#exports(name, &block) ⇒ Object
Public: Registers an export artifact with a name and its properties defined in ‘Decidim::Exporters::ExportManifest`.
Export artifacts provide a unified way for processes to register exportable collections serialized via a ‘Serializer` that eventually are transformed to their formats.
name - The name of the artifact for this export. Should be unique in the context of the space. block - A block that receives the manifest as its only argument.
Returns nothing.
      174 175 176 177 178 179 180  | 
    
      # File 'lib/decidim/participatory_space_manifest.rb', line 174 def exports(name, &block) return unless name @exports ||= [] @exports << [name, block] @export_manifests = nil end  | 
  
#invoke_on_destroy_account(user) ⇒ Object
      199 200 201 202 203  | 
    
      # File 'lib/decidim/participatory_space_manifest.rb', line 199 def invoke_on_destroy_account(user) return unless @on_destroy_account @on_destroy_account.call(user) end  | 
  
#participatory_spaces(&block) ⇒ Object
Public: A block that retrieves all the participatory spaces for the manifest. The block receives a ‘Decidim::Organization` as a parameter in order to filter. The block is expected to return an `ActiveRecord::Association`.
Returns nothing.
      117 118 119  | 
    
      # File 'lib/decidim/participatory_space_manifest.rb', line 117 def participatory_spaces(&block) @participatory_spaces ||= block end  | 
  
#permissions_class ⇒ Object
Public: Finds the permission class from its name, using the ‘permissions_class_name` attribute. If the class does not exist, it raises an exception. If the class name is not set, it returns nil.
Returns a Class.
      126 127 128  | 
    
      # File 'lib/decidim/participatory_space_manifest.rb', line 126 def &.constantize end  | 
  
#register_on_destroy_account(&block) ⇒ Object
The block is a callback that will be invoked with the destroyed ‘user` as argument.
      195 196 197  | 
    
      # File 'lib/decidim/participatory_space_manifest.rb', line 195 def register_on_destroy_account(&block) @on_destroy_account = block end  | 
  
#register_resource(name) ⇒ Object
Public: Registers a resource. Exposes a DSL defined by ‘Decidim::ResourceManifest`.
Resource manifests are a way to expose a resource from one engine to the whole system. This way resources can be linked between them.
name - A name for that resource. Should be singular (ie not plural). block - A Block that will be called to set the Resource attributes.
Returns nothing.
      158 159 160  | 
    
      # File 'lib/decidim/participatory_space_manifest.rb', line 158 def register_resource(name, &) Decidim.register_resource(name, &) end  | 
  
#register_stat(name, options = {}) ⇒ Object
Public: Registers a stat inside a participatory_space manifest.
name - The name of the stat options - A hash of options
* primary: Whether the stat is primary or not.
* priority: The priority of the stat used for render issues.
block - A block that receive the components to filter out the stat.
Returns nothing.
      144 145 146  | 
    
      # File 'lib/decidim/participatory_space_manifest.rb', line 144 def register_stat(name, = {}, &) stats.register(name, , &) end  | 
  
#route_name ⇒ Object
The name of the named Rails route to create the url to the resource.
Returns a String.
      108 109 110  | 
    
      # File 'lib/decidim/participatory_space_manifest.rb', line 108 def route_name super || model_class_name.demodulize.underscore end  | 
  
#seed! ⇒ Object
Public: Creates the seeds for this components in order to populate the database.
Returns nothing.
      100 101 102 103  | 
    
      # File 'lib/decidim/participatory_space_manifest.rb', line 100 def seed! print "Creating seeds for the #{name} space...\n" unless Rails.env.test? # rubocop:disable Rails/Output @seeds&.call end  | 
  
#seeds(&block) ⇒ Object
Public: A block that gets called when seeding for this component takes place.
Returns nothing.
      93 94 95  | 
    
      # File 'lib/decidim/participatory_space_manifest.rb', line 93 def seeds(&block) @seeds = block end  | 
  
#stats ⇒ Object
Public: Stores an instance of StatsRegistry
      131 132 133  | 
    
      # File 'lib/decidim/participatory_space_manifest.rb', line 131 def stats @stats ||= StatsRegistry.new end  |