class Jennifer::Config

Overview

Configuration container.

At the moment it implements singleton pattern but can be scaled to support several configuration instances per application.

All class methods with same names as instance ones delegates the calls to default configuration (global) object.

Supported configurations:

Jennifer::Config.configure do |conf|
  conf.host = "localhost"
  conf.user = "root"
  conf.password = ""
  conf.adapter = "mysql"
  conf.db = "crystal"
end

Defined in:

jennifer/config.cr

Constant Summary

LOG_CONTEXT = "db"

Context name used for logger.

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.config : self #

Returns default configuration object.


[View source]
def self.configure : self #

Returns default configuration object.


[View source]
def self.instance : self #

Default configuration object used by application.


[View source]
def self.new #

[View source]
def self.reset_config : Config #

Reinitialize new configuration object with default values


[View source]

Class Method Detail

def self.adapter #

Delegates to #adapter.


def self.adapter=(value) #

Delegates to #adapter=.


def self.allow_outdated_pending_migration #

def self.allow_outdated_pending_migration=(value) #

def self.checkout_timeout #

Delegates to #checkout_timeout.


def self.checkout_timeout=(value) #

Delegates to #checkout_timeout=.


def self.command_shell #

Delegates to #command_shell.


def self.command_shell=(value) #

Delegates to #command_shell=.


def self.command_shell_sudo #

Delegates to #command_shell_sudo.


def self.command_shell_sudo=(value) #

Delegates to #command_shell_sudo=.


def self.configure(&) #

Yields default configuration instance to block and validates it.


[View source]
def self.db #

Delegates to #db.


def self.db=(value) #

Delegates to #db=.


def self.docker_container #

Delegates to #docker_container.


def self.docker_container=(value) #

Delegates to #docker_container=.


def self.docker_source_location #

Delegates to #docker_source_location.


def self.docker_source_location=(value) #

Delegates to #docker_source_location=.


def self.from_uri(uri) #

Delegates call to #from_uri.


[View source]
def self.host #

Delegates to #host.


def self.host=(value) #

Delegates to #host=.


def self.initial_pool_size #

Delegates to #initial_pool_size.


def self.initial_pool_size=(value) #

Delegates to #initial_pool_size=.


def self.local_time_zone #

Delegates call to #local_time_zone.


[View source]
def self.local_time_zone_name #

Delegates to #local_time_zone_name.


def self.local_time_zone_name=(value) #

Delegates to #local_time_zone_name=.


def self.logger #

Delegates to #:logger.


[View source]
def self.logger=(value) #

Delegates to #:logger=.


[View source]
def self.max_bind_vars_count #

Delegates to #:max_bind_vars_count.


[View source]
def self.max_bind_vars_count=(value) #

Delegates to #:max_bind_vars_count=.


[View source]
def self.max_idle_pool_size #

Delegates to #max_idle_pool_size.


def self.max_idle_pool_size=(value) #

Delegates to #max_idle_pool_size=.


def self.max_pool_size #

Delegates to #max_pool_size.


def self.max_pool_size=(value) #

Delegates to #max_pool_size=.


def self.migration_files_path #

Delegates to #migration_files_path.


def self.migration_files_path=(value) #

Delegates to #migration_files_path=.


def self.model_files_path #

Delegates to #model_files_path.


def self.model_files_path=(value) #

Delegates to #model_files_path=.


def self.password #

Delegates to #password.


def self.password=(value) #

Delegates to #password=.


def self.port #

Delegates to #port.


def self.port=(value) #

Delegates to #port=.


def self.read(*args, **opts) #

Delegates call to #read.


[View source]
def self.read(*args, **opts, &) #

[View source]
def self.retry_attempts #

Delegates to #retry_attempts.


def self.retry_attempts=(value) #

Delegates to #retry_attempts=.


def self.retry_delay #

Delegates to #retry_delay.


def self.retry_delay=(value) #

Delegates to #retry_delay=.


def self.schema #

Delegates to #schema.


def self.schema=(value) #

Delegates to #schema=.


def self.skip_dumping_schema_sql #

Delegates to #skip_dumping_schema_sql.


def self.skip_dumping_schema_sql=(value) #

def self.structure_folder #

Delegates to #structure_folder.


def self.structure_folder=(value) #

Delegates to #structure_folder=.


def self.structure_path : String #

Delegates call to #structure_path.


[View source]
def self.time_zone_aware_attributes #

def self.time_zone_aware_attributes=(value) #

def self.user #

Delegates to #user.


def self.user=(value) #

Delegates to #user=.


def self.verbose_migrations #

Delegates to #verbose_migrations.


def self.verbose_migrations=(value) #

Delegates to #verbose_migrations=.


Instance Method Detail

def adapter : String #

def adapter=(adapter) #

def allow_outdated_pending_migration : Bool #

def allow_outdated_pending_migration=(allow_outdated_pending_migration) #

def checkout_timeout : Float64 #

def checkout_timeout=(checkout_timeout) #

def command_shell : String #

def command_shell=(command_shell) #

def command_shell_sudo : Bool #

def command_shell_sudo=(command_shell_sudo) #

def db : String #

def db=(db) #

def docker_container : String #

def docker_container=(docker_container) #

def docker_source_location : String #

def docker_source_location=(docker_source_location) #

def from_uri(uri : String) #

Reads configuration properties from the given uri string.

Jennifer::Config.from_uri("mysql://root:password@somehost:3306/some_database")

[View source]
def from_uri(uri : URI) #

Reads configuration properties from the given uri.


[View source]
def from_yaml(source) #

Reads configuration properties from the given YAML source.


[View source]
def host : String #

def host=(host) #

def initial_pool_size : Int32 #

def initial_pool_size=(initial_pool_size) #

def local_time_zone : Time::Location #

Returns local time zone.


[View source]
def local_time_zone_name : String #

def local_time_zone_name=(value : String) #

[View source]
def local_time_zone_name=(local_time_zone_name) #

def logger : Log #

Log instance.

Default is Log.for("db", Log::Severity::Debug)


[View source]
def logger=(logger : Log) #

Log instance.

Default is Log.for("db", Log::Severity::Debug)


[View source]
def max_bind_vars_count : Int32? #

Maximum count of bind variables.

If nil - uses default adapter value.


[View source]
def max_bind_vars_count=(max_bind_vars_count : Int32?) #

Maximum count of bind variables.

If nil - uses default adapter value.


[View source]
def max_idle_pool_size : Int32 #

def max_idle_pool_size=(max_idle_pool_size) #

def max_pool_size : Int32 #

def max_pool_size=(max_pool_size) #

def migration_failure_handler_method : Jennifer::Config::MigrationFailureHandler #

Handler type for the failed migrations; default is "none".


[View source]
def migration_failure_handler_method=(value : MigrationFailureHandler) #

[View source]
def migration_files_path : String #

def migration_files_path=(migration_files_path) #

def model_files_path : String #

def model_files_path=(model_files_path) #

def password : String #

def password=(password) #

def pool_size #

Returns maximum size of the pool.


[View source]
def pool_size=(value : Int32) #

Sets #max_pool_size, #max_idle_pool_size and #initial_pool_size to the given value.


[View source]
def port : Int32 #

def port=(port) #

def read(path : String, env : Symbol = :development) #

Reads configurations from the file with given path for given env.

All configuration properties will be read from the env key.

Jennifer::Config.read("./db/database.yml", :production)

[View source]
def read(path : String, env : String) #

Reads configurations from the file with given path for given env.

All configuration properties will be read from the env key.

Jennifer::Config.read("./db/database.yml", :production)

[View source]
def read(path : String, &) #

Reads configurations from the file with given path.

It is considered that all configuration properties are located at the root level.


[View source]
def retry_attempts : Int32 #

def retry_attempts=(retry_attempts) #

def retry_delay : Float64 #

def retry_delay=(retry_delay) #

def schema : String #

Defines postgres database schema name (postgres specific configuration).


[View source]
def schema=(schema) #

def skip_dumping_schema_sql : Bool #

def skip_dumping_schema_sql=(skip_dumping_schema_sql) #

def structure_folder : String #

Returns schema.sql folder name.


[View source]
def structure_folder=(structure_folder) #

def structure_path : String #

Return path to structure.sql file.


[View source]
def time_zone_aware_attributes : Bool #

Whether Jennifer should convert time objects to UTC and back to application time zone when store/load them from a database.

If set to false all time objects will be treated as local time - Time#to_local_in will be used instead of Time#in.


[View source]
def time_zone_aware_attributes=(time_zone_aware_attributes) #

def user : String #

def user=(user) #

def verbose_migrations : Bool #

Returns whether migrations should be performed in verbose mode.

Default is true.


[View source]
def verbose_migrations=(verbose_migrations) #