Class: Decidim::Command
- Inherits:
-
Object
show all
- Includes:
- Wisper::Publisher
- Defined in:
- lib/decidim/command.rb
Direct Known Subclasses
AcceptGroupInvitation, AcceptUserGroupJoinRequest, Amendable::Accept, Amendable::CreateDraft, Amendable::DestroyDraft, Amendable::Promote, Amendable::PublishDraft, Amendable::Reject, Amendable::UpdateDraft, Amendable::Withdraw, CreateEditorImage, CreateFollow, CreateOmniauthRegistration, CreateRegistration, CreateReport, CreateUserGroup, CreateUserReport, DeleteFollow, DemoteMembership, DestroyAccount, EndorseResource, InviteUser, InviteUserAgain, InviteUserToGroup, JoinUserGroup, LeaveUserGroup, Messaging::ReplyToConversation, Messaging::StartConversation, PromoteMembership, RejectGroupInvitation, RejectUserGroupJoinRequest, RemoveUserFromGroup, ResendConfirmationInstructions, Search, UnendorseResource, UnsubscribeSettings, UpdateAccount, UpdateNotificationsSettings, UpdatePassword, UpdateUserGroup, UpdateUserInterests, ValidateUpload
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 '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 '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 '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
40
41
42
|
# File '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 'lib/decidim/command.rb', line 28
def transaction(&block)
ActiveRecord::Base.transaction(&block) if block_given?
end
|