Class: Decidim::Command

Inherits:
Object
  • Object
show all
Includes:
Wisper::Publisher
Defined in:
decidim-core/lib/decidim/command.rb

Direct Known Subclasses

AcceptGroupInvitation, AcceptUserGroupJoinRequest, Accountability::Admin::CreateImportedResult, Accountability::Admin::CreateResult, Accountability::Admin::CreateStatus, Accountability::Admin::CreateTimelineEntry, Accountability::Admin::DestroyResult, Accountability::Admin::UpdateImportedResult, Accountability::Admin::UpdateResult, Accountability::Admin::UpdateStatus, Accountability::Admin::UpdateTimelineEntry, Admin::BlockUser, Admin::CloseSessionManagedUser, Admin::CreateArea, Admin::CreateAreaType, Admin::CreateAttachment, Admin::CreateAttachmentCollection, Admin::CreateCategory, Admin::CreateComponent, Admin::CreateImport, Admin::CreateImportExample, Admin::CreateNewsletter, Admin::CreateParticipatorySpacePrivateUser, Admin::CreateScope, Admin::CreateScopeType, Admin::CreateStaticPage, Admin::CreateStaticPageTopic, Admin::DeliverNewsletter, Admin::DestroyArea, Admin::DestroyCategory, Admin::DestroyComponent, Admin::DestroyNewsletter, Admin::DestroyParticipatorySpacePrivateUser, Admin::DestroyScope, Admin::DestroyShareToken, Admin::DestroyStaticPage, Admin::DestroyStaticPageTopic, Admin::HideResource, Admin::ImpersonateUser, Admin::InviteAdmin, Admin::OfficializeUser, Admin::ProcessParticipatorySpacePrivateUserImportCsv, Admin::ProcessUserGroupVerificationCsv, Admin::PromoteManagedUser, Admin::PublishComponent, Admin::RejectUserGroup, Admin::RemoveAdmin, Admin::ReorderContentBlocks, Admin::TransferUser, Admin::UnblockUser, Admin::UnhideResource, Admin::UnofficializeUser, Admin::UnpublishComponent, Admin::UnreportResource, Admin::UnreportUser, Admin::UpdateArea, Admin::UpdateAreaType, Admin::UpdateAttachment, Admin::UpdateAttachmentCollection, Admin::UpdateCategory, Admin::UpdateComponent, Admin::UpdateComponentPermissions, Admin::UpdateContentBlock, Admin::UpdateExternalDomainWhitelist, Admin::UpdateHelpSections, Admin::UpdateNewsletter, Admin::UpdateOrganization, Admin::UpdateOrganizationAppearance, Admin::UpdateOrganizationTosVersion, Admin::UpdateResourcePermissions, Admin::UpdateScope, Admin::UpdateScopeType, Admin::UpdateStaticPage, Admin::UpdateStaticPageTopic, Admin::UpdateUserGroups, Admin::VerifyUserGroup, Amendable::Accept, Amendable::CreateDraft, Amendable::DestroyDraft, Amendable::Promote, Amendable::PublishDraft, Amendable::Reject, Amendable::UpdateDraft, Amendable::Withdraw, Assemblies::Admin::CopyAssembly, Assemblies::Admin::CreateAssembliesType, Assemblies::Admin::CreateAssembly, Assemblies::Admin::CreateAssemblyMember, Assemblies::Admin::DestroyAssembliesType, Assemblies::Admin::DestroyAssemblyAdmin, Assemblies::Admin::DestroyAssemblyMember, Assemblies::Admin::ImportAssembly, Assemblies::Admin::NotifyRoleAssignedToAssembly, Assemblies::Admin::PublishAssembly, Assemblies::Admin::UnpublishAssembly, Assemblies::Admin::UpdateAssembliesSetting, Assemblies::Admin::UpdateAssembliesType, Assemblies::Admin::UpdateAssembly, Assemblies::Admin::UpdateAssemblyMember, Blogs::Admin::CreatePost, Blogs::Admin::UpdatePost, Budgets::AddLineItem, Budgets::Admin::CreateBudget, Budgets::Admin::CreateOrderReminders, Budgets::Admin::CreateProject, Budgets::Admin::DestroyBudget, Budgets::Admin::DestroyProject, Budgets::Admin::ImportProposalsToBudgets, Budgets::Admin::UpdateBudget, Budgets::Admin::UpdateProject, Budgets::CancelOrder, Budgets::Checkout, Budgets::RemoveLineItem, Decidim::Comments::CreateComment, Decidim::Comments::DeleteComment, Decidim::Comments::UpdateComment, Decidim::Comments::VoteComment, Decidim::Conferences::Admin::ConfirmConferenceRegistration, Decidim::Conferences::Admin::CopyConference, Decidim::Conferences::Admin::CreateConference, Decidim::Conferences::Admin::CreateConferenceSpeaker, Decidim::Conferences::Admin::CreateMediaLink, Decidim::Conferences::Admin::CreatePartner, Decidim::Conferences::Admin::CreateRegistrationType, Decidim::Conferences::Admin::DestroyConferenceAdmin, Decidim::Conferences::Admin::DestroyConferenceSpeaker, Decidim::Conferences::Admin::DestroyMediaLink, Decidim::Conferences::Admin::DestroyPartner, Decidim::Conferences::Admin::DestroyRegistrationType, Decidim::Conferences::Admin::ExportConferenceRegistrations, Decidim::Conferences::Admin::InviteUserToJoinConference, Decidim::Conferences::Admin::NotifyRoleAssignedToConference, Decidim::Conferences::Admin::PublishConference, Decidim::Conferences::Admin::PublishRegistrationType, Decidim::Conferences::Admin::SendConferenceDiplomas, Decidim::Conferences::Admin::UnpublishConference, Decidim::Conferences::Admin::UnpublishRegistrationType, Decidim::Conferences::Admin::UpdateConference, Decidim::Conferences::Admin::UpdateConferenceSpeaker, Decidim::Conferences::Admin::UpdateDiploma, Decidim::Conferences::Admin::UpdateMediaLink, Decidim::Conferences::Admin::UpdatePartner, Decidim::Conferences::Admin::UpdateRegistrationType, Decidim::Conferences::DeclineInvitation, Decidim::Conferences::JoinConference, Decidim::Conferences::LeaveConference, Decidim::Consultations::Admin::CreateConsultation, Decidim::Consultations::Admin::CreateQuestion, Decidim::Consultations::Admin::CreateResponse, Decidim::Consultations::Admin::CreateResponseGroup, Decidim::Consultations::Admin::DestroyResponseGroup, Decidim::Consultations::Admin::PublishConsultation, Decidim::Consultations::Admin::PublishConsultationResults, Decidim::Consultations::Admin::PublishQuestion, Decidim::Consultations::Admin::UnpublishConsultation, Decidim::Consultations::Admin::UnpublishConsultationResults, Decidim::Consultations::Admin::UnpublishQuestion, Decidim::Consultations::Admin::UpdateConsultation, Decidim::Consultations::Admin::UpdateQuestion, Decidim::Consultations::Admin::UpdateQuestionConfiguration, Decidim::Consultations::Admin::UpdateResponse, Decidim::Consultations::Admin::UpdateResponseGroup, Decidim::Consultations::MultipleVoteQuestion, Decidim::Consultations::UnvoteQuestion, Decidim::Consultations::VoteQuestion, CreateEditorImage, CreateFollow, CreateOmniauthRegistration, CreateRegistration, CreateReport, CreateUserGroup, CreateUserReport, Debates::Admin::CloseDebate, Debates::Admin::CreateDebate, Debates::Admin::UpdateDebate, Debates::CloseDebate, Debates::CreateDebate, Debates::UpdateDebate, DeleteFollow, DemoteMembership, DestroyAccount, DummyResources::CreateDummyResource, Elections::Admin::AddUserAsTrustee, Elections::Admin::CreateAnswer, Elections::Admin::CreateElection, Elections::Admin::CreateQuestion, Elections::Admin::DestroyAnswer, Elections::Admin::DestroyElection, Elections::Admin::DestroyQuestion, Elections::Admin::EndVote, Elections::Admin::ImportProposalsToElections, Elections::Admin::PublishElection, Elections::Admin::PublishResults, Elections::Admin::RemoveTrusteeFromParticipatorySpace, Elections::Admin::ReportMissingTrustee, Elections::Admin::SetupElection, Elections::Admin::StartKeyCeremony, Elections::Admin::StartTally, Elections::Admin::StartVote, Elections::Admin::UnpublishElection, Elections::Admin::UpdateActionStatus, Elections::Admin::UpdateAnswer, Elections::Admin::UpdateAnswerSelection, Elections::Admin::UpdateElection, Elections::Admin::UpdateQuestion, Elections::Admin::UpdateTrusteeParticipatorySpace, Elections::TrusteeZone::UpdateElectionBulletinBoardStatus, Elections::TrusteeZone::UpdateTrustee, Elections::Voter::CastVote, Elections::Voter::UpdateVoteStatus, EndorseResource, Forms::Admin::UpdateQuestionnaire, Forms::AnswerQuestionnaire, Initiatives::Admin::CreateInitiativeType, Initiatives::Admin::CreateInitiativeTypeScope, Initiatives::Admin::PublishInitiative, Initiatives::Admin::SendInitiativeToTechnicalValidation, Initiatives::Admin::UnpublishInitiative, Initiatives::Admin::UpdateInitiative, Initiatives::Admin::UpdateInitiativeAnswer, Initiatives::Admin::UpdateInitiativeType, Initiatives::Admin::UpdateInitiativeTypeScope, Initiatives::ApproveMembershipRequest, Initiatives::CreateInitiative, Initiatives::RevokeMembershipRequest, Initiatives::SendInitiativeToTechnicalValidation, Initiatives::SpawnCommitteeRequest, Initiatives::UnvoteInitiative, Initiatives::UpdateInitiative, Initiatives::ValidateMobilePhone, Initiatives::ValidateSmsCode, Initiatives::VoteInitiative, InviteUser, InviteUserAgain, InviteUserToGroup, JoinUserGroup, LeaveUserGroup, Meetings::Admin::CloseMeeting, Meetings::Admin::CopyMeeting, Meetings::Admin::CreateAgenda, Meetings::Admin::CreateMeeting, Meetings::Admin::DestroyMeeting, Meetings::Admin::ExportMeetingRegistrations, Meetings::Admin::InviteUserToJoinMeeting, Meetings::Admin::PublishMeeting, Meetings::Admin::UnpublishMeeting, Meetings::Admin::UpdateAgenda, Meetings::Admin::UpdateMeeting, Meetings::Admin::UpdateQuestionStatus, Meetings::Admin::UpdateQuestionnaire, Meetings::Admin::UpdateRegistrations, Meetings::Admin::ValidateRegistrationCode, Meetings::CloseMeeting, Meetings::CreateAnswer, Meetings::CreateMeeting, Meetings::DeclineInvitation, Meetings::JoinMeeting, Meetings::LeaveMeeting, Meetings::UpdateMeeting, Meetings::WithdrawMeeting, Messaging::ReplyToConversation, Messaging::StartConversation, Pages::Admin::UpdatePage, Pages::CopyPage, Pages::CreatePage, Pages::DestroyPage, ParticipatoryProcesses::Admin::ActivateParticipatoryProcessStep, ParticipatoryProcesses::Admin::CopyParticipatoryProcess, ParticipatoryProcesses::Admin::CreateParticipatoryProcess, ParticipatoryProcesses::Admin::CreateParticipatoryProcessGroup, ParticipatoryProcesses::Admin::CreateParticipatoryProcessStep, ParticipatoryProcesses::Admin::CreateParticipatoryProcessType, ParticipatoryProcesses::Admin::DestroyParticipatoryProcessAdmin, ParticipatoryProcesses::Admin::DestroyParticipatoryProcessGroup, ParticipatoryProcesses::Admin::DestroyParticipatoryProcessStep, ParticipatoryProcesses::Admin::DestroyParticipatoryProcessType, ParticipatoryProcesses::Admin::ImportParticipatoryProcess, ParticipatoryProcesses::Admin::NotifyRoleAssignedToParticipatoryProcess, ParticipatoryProcesses::Admin::PublishParticipatoryProcess, ParticipatoryProcesses::Admin::ReorderParticipatoryProcessSteps, ParticipatoryProcesses::Admin::UnpublishParticipatoryProcess, ParticipatoryProcesses::Admin::UpdateParticipatoryProcess, ParticipatoryProcesses::Admin::UpdateParticipatoryProcessGroup, ParticipatoryProcesses::Admin::UpdateParticipatoryProcessStep, ParticipatoryProcesses::Admin::UpdateParticipatoryProcessType, PromoteMembership, Proposals::AcceptAccessToCollaborativeDraft, Proposals::Admin::AnswerProposal, Proposals::Admin::AssignProposalsToValuator, Proposals::Admin::CreateProposal, Proposals::Admin::CreateProposalNote, Proposals::Admin::DiscardParticipatoryText, Proposals::Admin::ImportParticipatoryText, Proposals::Admin::ImportProposals, Proposals::Admin::MergeProposals, Proposals::Admin::NotifyProposalAnswer, Proposals::Admin::PublishAnswers, Proposals::Admin::SplitProposals, Proposals::Admin::UnassignProposalsFromValuator, Proposals::Admin::UpdateParticipatoryText, Proposals::Admin::UpdateProposal, Proposals::Admin::UpdateProposalCategory, Proposals::Admin::UpdateProposalScope, Proposals::CreateCollaborativeDraft, Proposals::CreateProposal, Proposals::DestroyProposal, Proposals::PublishCollaborativeDraft, Proposals::PublishProposal, Proposals::RejectAccessToCollaborativeDraft, Proposals::RequestAccessToCollaborativeDraft, Proposals::UnvoteProposal, Proposals::UpdateCollaborativeDraft, Proposals::UpdateProposal, Proposals::VoteProposal, Proposals::WithdrawCollaborativeDraft, Proposals::WithdrawProposal, RejectGroupInvitation, RejectUserGroupJoinRequest, RemoveUserFromGroup, ResendConfirmationInstructions, Search, Sortitions::Admin::CreateSortition, Sortitions::Admin::DestroySortition, Sortitions::Admin::UpdateSortition, Surveys::CreateSurvey, System::CreateAdmin, System::CreateDefaultContentBlocks, System::CreateDefaultPages, System::CreateOAuthApplication, System::DestroyOAuthApplication, System::PopulateHelp, System::RegisterOrganization, System::UpdateAdmin, System::UpdateOAuthApplication, System::UpdateOrganization, Templates::Admin::ApplyQuestionnaireTemplate, Templates::Admin::CopyQuestionnaireTemplate, Templates::Admin::CreateQuestionnaireTemplate, Templates::Admin::DestroyTemplate, Templates::Admin::UpdateTemplate, UnendorseResource, UnsubscribeSettings, UpdateAccount, UpdateNotificationsSettings, UpdateUserGroup, UpdateUserInterests, ValidateUpload, Verifications::AuthorizeUser, Verifications::ConfirmUserAuthorization, Verifications::CsvCensus::Admin::CreateCensusData, Verifications::DestroyUserAuthorization, Verifications::IdDocuments::Admin::ConfirmUserOfflineAuthorization, Verifications::IdDocuments::Admin::UpdateConfig, Verifications::PerformAuthorizationStep, Verifications::RevokeAllAuthorizations, Verifications::RevokeByConditionAuthorizations, Votings::Admin::CreateBallotStyle, Votings::Admin::CreateMonitoringCommitteeMember, Votings::Admin::CreatePollingOfficer, Votings::Admin::CreateVoting, Votings::Admin::DestroyBallotStyle, Votings::Admin::DestroyMonitoringCommitteeMember, Votings::Admin::DestroyPollingOfficer, Votings::Admin::DestroyPollingStation, Votings::Admin::ManagePollingStation, Votings::Admin::MonitoringCommitteeValidatePollingStationClosure, Votings::Admin::PublishVoting, Votings::Admin::UnpublishVoting, Votings::Admin::UpdateBallotStyle, Votings::Admin::UpdateVoting, Votings::Census::Admin::CreateDataset, Votings::Census::Admin::CreateDatum, Votings::Census::Admin::DestroyDataset, Votings::Census::Admin::IncrementDatasetProcessedRows, Votings::Census::Admin::LaunchAccessCodesExport, Votings::Census::Admin::LaunchAccessCodesGeneration, Votings::Census::Admin::UpdateDataset, Votings::CertifyPollingStationClosure, Votings::CheckCensus, Votings::CreatePollingStationClosure, Votings::CreatePollingStationResults, Votings::SendAccessCode, Votings::SignPollingStationClosure, Votings::Voter::InPersonVote, Votings::Voter::UpdateInPersonVoteStatus

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name) ⇒ Object


32
33
34
35
36
37
38
# File 'decidim-core/lib/decidim/command.rb', line 32

def method_missing(method_name, ...)
  if @caller.respond_to?(method_name, true)
    @caller.send(method_name, ...)
  else
    super
  end
end

Class Method Details

.call(*args, **kwargs, &block) ⇒ Object


12
13
14
15
16
17
18
19
20
21
# File 'decidim-core/lib/decidim/command.rb', line 12

def self.call(*args, **kwargs, &block)
  event_recorder = Decidim::EventRecorder.new

  command = new(*args, **kwargs)
  command.subscribe(event_recorder)
  command.evaluate(&block) if block_given?
  command.call

  event_recorder.events
end

Instance Method Details

#evaluate(&block) ⇒ Object


23
24
25
26
# File 'decidim-core/lib/decidim/command.rb', line 23

def evaluate(&block)
  @caller = eval("self", block.binding, __FILE__, __LINE__)
  instance_eval(&block)
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)

40
41
42
# File 'decidim-core/lib/decidim/command.rb', line 40

def respond_to_missing?(method_name, include_private = false)
  @caller.respond_to?(method_name, include_private)
end

#transaction(&block) ⇒ Object


28
29
30
# File 'decidim-core/lib/decidim/command.rb', line 28

def transaction(&block)
  ActiveRecord::Base.transaction(&block) if block_given?
end