module DCA::Storage::ClassMethods

Public Instance Methods

establish_connection(config_name = :db) click to toggle source
# File lib/dca/storage/storage.rb, line 6
def establish_connection config_name = :db
  @config = APP_CONFIG[config_name]
end
root_storage() click to toggle source
# File lib/dca/storage/storage.rb, line 10
def root_storage
  return @storage if @storage

  return storage if @config

  superclass.root_storage if superclass != Object
end
storage() click to toggle source
# File lib/dca/storage/storage.rb, line 18
def storage
  return @storage unless @storage.nil?

  if @config
    driver_class = "DCA::#{@config[:driver]}Storage".constantize
    connection = driver_class.establish_connection @config
    @storage = driver_class.new connection, self, @config
  else
    @storage = superclass.root_storage.context self
  end
end