Class: Lore::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/lore/connection.rb

Constant Summary collapse

@@logger =
Lore.logger
@@context_stack =
Array.new

Class Method Summary collapse

Class Method Details

.clearObject



41
42
43
44
# File 'lib/lore/connection.rb', line 41

def self.clear()
  @@context_stack = Array.new
  $cb__project = nil
end

.enter(context_name) ⇒ Object



31
32
33
34
# File 'lib/lore/connection.rb', line 31

def self.enter(context_name)
  Lore.log { 'Entering context ' + context_name.to_s }
  @@context_stack.push(context_name)
end

.get_connectionObject



20
21
22
23
24
25
# File 'lib/lore/connection.rb', line 20

def self.get_connection()
  if @@context_stack.empty? then
    raise ::Exception.new('No context given. ')
  end
  return Connection_Pool.get_connection(@@context_stack.last)
end

.inspectObject



27
28
29
# File 'lib/lore/connection.rb', line 27

def self.inspect
  @@context_stack.inspect
end

.leaveObject



36
37
38
39
# File 'lib/lore/connection.rb', line 36

def self.leave()
  context_name = @@context_stack.pop
  @@logger.debug('Leaving context ' << context_name.to_s)
end

.switch_to(project) ⇒ Object



46
47
48
49
50
# File 'lib/lore/connection.rb', line 46

def self.switch_to(project)
  clear()
  enter(project.context)
  $cb__project = project
end