Module: Capistrano::Configuration::Extensions::Execution
- Included in:
- Capistrano::Configuration
- Defined in:
- lib/capistrano/configuration/extensions/execution.rb
Instance Method Summary collapse
- #current_task ⇒ Object
- #on_rollback(&block) ⇒ Object
- #rollback! ⇒ Object
- #rollback_requests ⇒ Object
- #rollback_requests=(rollback_requests) ⇒ Object
- #task_call_frames ⇒ Object
- #transaction(&blk) ⇒ Object
- #transaction? ⇒ Boolean
Instance Method Details
#current_task ⇒ Object
18 19 20 21 22 |
# File 'lib/capistrano/configuration/extensions/execution.rb', line 18 def current_task all_task_call_frames = Thread.main[:task_call_frames] + task_call_frames return nil if all_task_call_frames.empty? all_task_call_frames.last.task end |
#on_rollback(&block) ⇒ Object
35 36 37 38 |
# File 'lib/capistrano/configuration/extensions/execution.rb', line 35 def on_rollback(&block) self.rollback_requests ||= [] if transaction? super end |
#rollback! ⇒ Object
40 41 42 43 44 |
# File 'lib/capistrano/configuration/extensions/execution.rb', line 40 def rollback! return if rollback_requests.nil? super Thread.current[:rolled_back] = true end |
#rollback_requests ⇒ Object
14 15 16 |
# File 'lib/capistrano/configuration/extensions/execution.rb', line 14 def rollback_requests Thread.current[:rollback_requests] end |
#rollback_requests=(rollback_requests) ⇒ Object
10 11 12 |
# File 'lib/capistrano/configuration/extensions/execution.rb', line 10 def rollback_requests=(rollback_requests) Thread.current[:rollback_requests] = rollback_requests end |
#task_call_frames ⇒ Object
6 7 8 |
# File 'lib/capistrano/configuration/extensions/execution.rb', line 6 def task_call_frames Thread.current[:task_call_frames] ||= [] end |
#transaction(&blk) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/capistrano/configuration/extensions/execution.rb', line 28 def transaction(&blk) super do self.rollback_requests = [] unless transaction? blk.call end end |
#transaction? ⇒ Boolean
24 25 26 |
# File 'lib/capistrano/configuration/extensions/execution.rb', line 24 def transaction? !(rollback_requests.nil? && Thread.main[:rollback_requests].nil?) end |