Class: EPIC::DB

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
src/epic_sequel.rb

Overview

TODO:

multi-host sites

Instance Method Summary (collapse)

Constructor Details

- (DB) initialize

A new instance of DB



41
42
43
44
# File 'src/epic_sequel.rb', line 41

def initialize
  @all_nas = nil
  @pool = []
end

Instance Method Details

- (void) all_handle_values(handle)



63
64
65
# File 'src/epic_sequel.rb', line 63

def all_handle_values handle
  ds = self.pool[:handles].where( :handle => handle ).all
end

- (void) all_nas



46
47
48
# File 'src/epic_sequel.rb', line 46

def all_nas
  @all_nas ||= self.pool[:nas].select(:na).collect { |row| row[:na] }
end

- (void) each_handle(prefix = nil)



50
51
52
53
54
55
56
57
58
59
60
61
# File 'src/epic_sequel.rb', line 50

def each_handle prefix = nil
  ds = self.pool[:handles].select(:handle).distinct
  if prefix
    ds = ds.filter( '`handle` LIKE ?', prefix.to_s + '/%' )
  end
  self.sql_depth = self.sql_depth + 1
  begin
    ds.each { |row| yield row[:handle] }
  ensure
    self.sql_depth = self.sql_depth - 1
  end
end

- (void) pool



29
30
31
# File 'src/epic_sequel.rb', line 29

def pool
  @pool[self.sql_depth] ||= Sequel.connect(*SEQUEL_CONNECTION_ARGS)
end

- (void) sql_depth



33
34
35
# File 'src/epic_sequel.rb', line 33

def sql_depth
  Thread.current[:epic_sql_depth] ||= 0
end

- (void) sql_depth=(n)



37
38
39
# File 'src/epic_sequel.rb', line 37

def sql_depth= n
  Thread.current[:epic_sql_depth] = n.to_i
end

- (void) uuid



67
68
69
# File 'src/epic_sequel.rb', line 67

def uuid
  self.pool['SELECT UUID()'].get
end