Module: Stagehand::Database::ConnectionStack
- Defined in:
- lib/stagehand/database.rb
Overview
Threadsafe tracking of the connection stack
Class Method Summary collapse
Class Method Details
.current_stack ⇒ Object
178 179 180 181 182 183 184 185 186 187 |
# File 'lib/stagehand/database.rb', line 178 def self.current_stack if stack = Thread.current.thread_variable_get('sparkle_connection_name_stack') stack else stack = Concurrent::Array.new stack << Rails.env.to_sym Thread.current.thread_variable_set('sparkle_connection_name_stack', stack) stack end end |
.last ⇒ Object
174 175 176 |
# File 'lib/stagehand/database.rb', line 174 def self.last current_stack.last end |
.pop ⇒ Object
170 171 172 |
# File 'lib/stagehand/database.rb', line 170 def self.pop current_stack.pop end |
.push(connection_name) ⇒ Object
166 167 168 |
# File 'lib/stagehand/database.rb', line 166 def self.push(connection_name) current_stack.push connection_name end |