Class: Decidim::Pages::CreatePage

Inherits:
Command
  • Object
show all
Defined in:
decidim-pages/app/commands/decidim/pages/create_page.rb

Overview

Command that gets called whenever a component's page has to be created. It usually happens as a callback when the component itself is created.

Instance Method Summary collapse

Methods inherited from Command

call, #evaluate, #method_missing, #respond_to_missing?, #transaction

Constructor Details

#initialize(component) ⇒ CreatePage

Returns a new instance of CreatePage.


8
9
10
# File 'decidim-pages/app/commands/decidim/pages/create_page.rb', line 8

def initialize(component)
  @component = component
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Decidim::Command

Instance Method Details

#callObject


12
13
14
15
16
# File 'decidim-pages/app/commands/decidim/pages/create_page.rb', line 12

def call
  @page = Page.new(component: @component)

  @page.save ? broadcast(:ok) : broadcast(:invalid)
end