Class: Decidim::Commands::CreateResource
- Inherits:
-
Decidim::Command
- Object
- Decidim::Command
- Decidim::Commands::CreateResource
- Includes:
- ResourceHandler
- Defined in:
- decidim-core/lib/decidim/commands/create_resource.rb
Direct Known Subclasses
Accountability::Admin::CreateImportedResult, Accountability::Admin::CreateResult, Accountability::Admin::CreateStatus, Accountability::Admin::CreateTimelineEntry, Admin::CreateArea, Admin::CreateAreaType, Admin::CreateCategory, Admin::CreateComponent, Admin::CreateNewsletter, Admin::CreateScope, Admin::CreateScopeType, Admin::CreateShareToken, Admin::CreateStaticPage, Admin::CreateStaticPageTopic, Admin::CreateTaxonomy, Admin::CreateTaxonomyFilter, Assemblies::Admin::CreateAssembliesType, Assemblies::Admin::CreateAssembly, Assemblies::Admin::CreateAssemblyMember, Blogs::Admin::CreatePost, Budgets::Admin::CreateBudget, Budgets::Admin::CreateProject, Decidim::Conferences::Admin::CreateConference, Decidim::Conferences::Admin::CreateConferenceSpeaker, Decidim::Conferences::Admin::CreateMediaLink, Decidim::Conferences::Admin::CreatePartner, Decidim::Conferences::Admin::CreateRegistrationType, Debates::Admin::CreateDebate, Debates::CreateDebate, Initiatives::Admin::CreateInitiativeType, Initiatives::Admin::CreateInitiativeTypeScope, Meetings::Admin::CreateAgenda, Meetings::Admin::CreateMeeting, Meetings::CreateMeeting, ParticipatoryProcesses::Admin::CreateParticipatoryProcess, ParticipatoryProcesses::Admin::CreateParticipatoryProcessGroup, ParticipatoryProcesses::Admin::CreateParticipatoryProcessStep, ParticipatoryProcesses::Admin::CreateParticipatoryProcessType, Proposals::Admin::CreateProposalState
Instance Method Summary collapse
-
#call ⇒ Object
Creates the result if valid.
-
#initialize(form) ⇒ CreateResource
constructor
Initializes the command.
Methods inherited from Decidim::Command
call, #evaluate, #method_missing, #respond_to_missing?, #transaction, #with_events
Constructor Details
#initialize(form) ⇒ CreateResource
Initializes the command.
10 11 12 |
# File 'decidim-core/lib/decidim/commands/create_resource.rb', line 10 def initialize(form) @form = form end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Decidim::Command
Instance Method Details
#call ⇒ Object
Creates the result if valid.
Broadcasts :ok if successful, :invalid otherwise.
17 18 19 20 21 22 23 24 25 26 27 |
# File 'decidim-core/lib/decidim/commands/create_resource.rb', line 17 def call return broadcast(:invalid) if invalid? perform! broadcast(:ok, resource) rescue ActiveRecord::RecordInvalid add_file_attribute_errors! broadcast(:invalid) rescue Decidim::Commands::HookError broadcast(:invalid) end |