Class: Decidim::Dev::CreateDummyResource
- Inherits:
-
Command
- Object
- Command
- Decidim::Dev::CreateDummyResource
- Includes:
- GalleryMethods
- Defined in:
- app/commands/decidim/dev/create_dummy_resource.rb
Instance Method Summary collapse
-
#call ⇒ Object
Creates the dummy_resource if valid.
-
#initialize(form) ⇒ CreateDummyResource
constructor
A new instance of CreateDummyResource.
Constructor Details
#initialize(form) ⇒ CreateDummyResource
Returns a new instance of CreateDummyResource.
8 9 10 |
# File 'app/commands/decidim/dev/create_dummy_resource.rb', line 8 def initialize(form) @form = form end |
Instance Method Details
#call ⇒ Object
Creates the dummy_resource if valid.
Broadcasts :ok if successful, :invalid otherwise.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/commands/decidim/dev/create_dummy_resource.rb', line 15 def call return broadcast(:invalid) if @form.invalid? if process_gallery? build_gallery return broadcast(:invalid) if gallery_invalid? end transaction do create_dummy_resource create_gallery if process_gallery? end broadcast(:ok) end |