Class: Decidim::Surveys::CreateSurvey
- Inherits:
-
Rectify::Command
- Object
- Rectify::Command
- Decidim::Surveys::CreateSurvey
- Defined in:
- decidim-surveys/app/commands/decidim/surveys/create_survey.rb
Overview
Command that gets called whenever a feature’s survey has to be created. It usually happens as a callback when the feature itself is created.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(feature) ⇒ CreateSurvey
constructor
A new instance of CreateSurvey.
Constructor Details
#initialize(feature) ⇒ CreateSurvey
8 9 10 |
# File 'decidim-surveys/app/commands/decidim/surveys/create_survey.rb', line 8 def initialize(feature) @feature = feature end |
Instance Method Details
#call ⇒ Object
12 13 14 15 16 |
# File 'decidim-surveys/app/commands/decidim/surveys/create_survey.rb', line 12 def call @survey = Survey.new(feature: @feature) @survey.save ? broadcast(:ok) : broadcast(:invalid) end |