Module: Stagehand::Database::ConnectionStack

Defined in:
lib/stagehand/database.rb

Overview

Threadsafe tracking of the connection stack

Constant Summary collapse

@@connection_name_stack =
Hash.new { |h,k| h[k] = [ Rails.env.to_sym ] }

Class Method Summary collapse

Class Method Details

.current_stackObject



160
161
162
# File 'lib/stagehand/database.rb', line 160

def self.current_stack
  @@connection_name_stack[Thread.current.object_id]
end

.lastObject



156
157
158
# File 'lib/stagehand/database.rb', line 156

def self.last
  current_stack.last
end

.popObject



152
153
154
# File 'lib/stagehand/database.rb', line 152

def self.pop
  current_stack.pop
end

.push(connection_name) ⇒ Object



148
149
150
# File 'lib/stagehand/database.rb', line 148

def self.push(connection_name)
  current_stack.push connection_name
end