Class: Greenfield::Database

Inherits:
Object
  • #Object
show all
Defined in:
lib/story_teller/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.



504
505
506
507
508
509
510
511
# File 'lib/story_teller/database.rb', line 504

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.



486
487
488
# File 'lib/story_teller/database.rb', line 486

def bootstrap
  @bootstrap
end

Class Method Details

.init(database_name) ⇒ Object



488
489
490
# File 'lib/story_teller/database.rb', line 488

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

.instance(*args) ⇒ Object



494
495
496
497
498
499
500
# File 'lib/story_teller/database.rb', line 494

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