Module: RDBr::Query::Connection::Records

Defined in:
lib/rdbr/query/connection.rb

Constant Summary collapse

MUTEX =
Mutex.new

Class Method Summary collapse

Class Method Details

.build(parent) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/rdbr/query/connection.rb', line 9

def build(parent)
  MUTEX.synchronize do
    name = "Record#{next_identifier}"
    const_set(name, Class.new(parent))
    [ const_get(name), name ]
  end
end

.next_identifierObject



21
22
23
# File 'lib/rdbr/query/connection.rb', line 21

def next_identifier
  @next_identifier = @next_identifier.to_i + 1
end

.remove(name) ⇒ Object



17
18
19
# File 'lib/rdbr/query/connection.rb', line 17

def remove(name)
  MUTEX.synchronize{ remove_const(name) if const_defined?(name, false) }
end