Class: Decidim::System::CreateDefaultContentBlocks
- Defined in:
- decidim-system/app/commands/decidim/system/create_default_content_blocks.rb
Overview
A command with all the business logic to create the default content blocks for a newly-created organization.
Constant Summary collapse
- DEFAULT_CONTENT_BLOCKS =
[:hero, :sub_hero, :highlighted_content_banner, :how_to_participate, :stats, :metrics, :footer_sub_hero].freeze
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(organization) ⇒ CreateDefaultContentBlocks
constructor
Public: Initializes the command.
Methods inherited from Command
call, #evaluate, #method_missing, #respond_to_missing?, #transaction
Constructor Details
#initialize(organization) ⇒ CreateDefaultContentBlocks
Public: Initializes the command.
form - A form object with the params.
14 15 16 |
# File 'decidim-system/app/commands/decidim/system/create_default_content_blocks.rb', line 14 def initialize(organization) @organization = organization end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Decidim::Command
Instance Method Details
#call ⇒ Object
Executes the command.
Returns nothing.
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'decidim-system/app/commands/decidim/system/create_default_content_blocks.rb', line 21 def call content_blocks.each_with_index do |manifest, index| weight = (index + 1) * 10 Decidim::ContentBlock.create( decidim_organization_id: organization.id, weight: weight, scope_name: :homepage, manifest_name: manifest.name, published_at: Time.current ) end end |