Class: Decidim::Pages::CreatePage

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

Overview

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

Instance Method Summary collapse

Constructor Details

#initialize(feature) ⇒ CreatePage

Returns a new instance of CreatePage.



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

def initialize(feature)
  @feature = feature
end

Instance Method Details

#callObject



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

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

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