Class: Inform::Database

Inherits:
Object show all
Defined in:
lib/runtime/database.rb

Overview

The Database abstraction class

Constant Summary collapse

REGISTRY =
Struct.new(:memo).new(defined?(Java) ? java.util.concurrent.ConcurrentHashMap.new : {})

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(database_name) ⇒ Database

Returns a new instance of Database.



483
484
485
486
487
488
489
490
# File 'lib/runtime/database.rb', line 483

def initialize(env = Game.environment)
  log.debug "Initializing persistence layer for environment: #{env}"
  log.debug caller[0..4]
  env ||= environment
  @config = database_config.fetch(env.to_s, {})
  establish_database_connection
  enable_plugins
end

Instance Attribute Details

#bootstrapObject (readonly)

Returns the value of attribute bootstrap.



465
466
467
# File 'lib/runtime/database.rb', line 465

def bootstrap
  @bootstrap
end

Class Method Details

.init(database_name) ⇒ Object



467
468
469
# File 'lib/runtime/database.rb', line 467

def self.init(database_name)
  Inform::Database.instance(database_name)
end

.instance(*args) ⇒ Object



473
474
475
476
477
478
479
# File 'lib/runtime/database.rb', line 473

def self.instance(*args)
  return @instance unless @instance.nil?
  @instance_mutex.synchronize do
    @instance ||= new(*args)
  end
  @instance
end