Module: Capistrano::Configuration::Extensions::Execution

Included in:
Capistrano::Configuration
Defined in:
lib/capistrano/configuration/extensions/execution.rb

Instance Method Summary collapse

Instance Method Details

#current_taskObject



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_requestsObject



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_framesObject



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

Returns:

  • (Boolean)


24
25
26
# File 'lib/capistrano/configuration/extensions/execution.rb', line 24

def transaction?
  !(rollback_requests.nil? && Thread.main[:rollback_requests].nil?)
end