class Ashikawa::Core::Configuration

Configuration of Ashikawa::Core

Attributes

adapter[RW]

The HTTP adapter instance @api private @return Object

connection[W]

The Connection object @api private @return Connection

database_name[W]

The name of the database you want to talk with @api private @return String

logger[RW]

The logger instance @api private @return Object

password[RW]

The password for authentication @api private @return String

url[RW]

The URL of the database instance @api private @return String

username[RW]

The username for authentication @api private @return String

Public Instance Methods

connection() click to toggle source

The Connection object @api private @return Connection

# File lib/ashikawa-core/configuration.rb, line 45
def connection
  @connection ||= setup_new_connection
  @connection.authenticate_with(username, password) if username && password
  @connection
end
database_name() click to toggle source

The name of the database you want to talk with @api private @return String

# File lib/ashikawa-core/configuration.rb, line 54
def database_name
  @database_name ||= '_system'
end

Private Instance Methods

connection_options() click to toggle source
# File lib/ashikawa-core/configuration.rb, line 73
def connection_options
  opts = {}
  opts[:logger] = logger if logger
  opts[:adapter] = adapter if adapter
  opts
end
setup_new_connection() click to toggle source

Setup the connection object

@param [String] url @param [Logger] logger @param [Adapter] adapter @return [Connection] @api private

# File lib/ashikawa-core/configuration.rb, line 67
def setup_new_connection
  raise(ArgumentError, 'Please provide either an url or a connection to setup the database') if url.nil?

  Connection.new(url, database_name, connection_options)
end