Module: CommandExtension::AfterCommit::InstanceMethods
- Defined in:
- lib/command_extension/after_commit.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
- #after_commit(method = nil, &block) ⇒ Object
- #after_commit_queue ⇒ Object
- #after_commit_queue_enabled? ⇒ Boolean
- #execute ⇒ Object
- #reset ⇒ Object
- #run_after_commit_queue ⇒ Object
- #subcommand(command) ⇒ Object
Instance Attribute Details
#after_commit_queue_enabled ⇒ Object
28 29 30 31 |
# File 'lib/command_extension/after_commit.rb', line 28 def after_commit_queue_enabled @after_commit_queue_enabled = true if @after_commit_queue_enabled.nil? @after_commit_queue_enabled end |
Instance Method Details
#after_commit(method = nil, &block) ⇒ Object
22 23 24 25 26 |
# File 'lib/command_extension/after_commit.rb', line 22 def after_commit(method = nil, &block) after_commit_queue << proc { send(method) } if method after_commit_queue << block if block true end |
#after_commit_queue ⇒ Object
13 14 15 |
# File 'lib/command_extension/after_commit.rb', line 13 def after_commit_queue @after_commit_queue ||= [] end |
#after_commit_queue_enabled? ⇒ Boolean
33 34 35 |
# File 'lib/command_extension/after_commit.rb', line 33 def after_commit_queue_enabled? after_commit_queue_enabled end |
#execute ⇒ Object
37 38 39 40 |
# File 'lib/command_extension/after_commit.rb', line 37 def execute run_after_commit_queue if after_commit_queue_enabled? super end |
#reset ⇒ Object
17 18 19 20 |
# File 'lib/command_extension/after_commit.rb', line 17 def reset @after_commit_queue = nil super end |
#run_after_commit_queue ⇒ Object
50 51 52 53 |
# File 'lib/command_extension/after_commit.rb', line 50 def run_after_commit_queue self.class.run_after_commit_queue(self) after_commit_queue.each(&:call) end |
#subcommand(command) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/command_extension/after_commit.rb', line 42 def subcommand(command) command.after_commit_queue_enabled = false after_commit do command.run_after_commit_queue end command end |