class Jennifer::Config
- Jennifer::Config
- Reference
- Object
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:
migration_files_path = "./db/migrations"verbose_migrations = truemodel_files_path = "./src/models"#structure_folderparent folder of#migration_files_pathhost = "localhost"port = -1logger = Log.for("db", :debug)schema = "public"#user#password#db#adapterpool_size = 1retry_attempts = 1checkout_timeout = 5.0retry_delay = 1.0#local_time_zone_namedefault time zone nameskip_dumping_schema_sql = falsecommand_shell = "bash"docker_container = ""docker_source_location = ""command_shell_sudo = falsemigration_failure_handler_method = :noneallow_outdated_pending_migration = falsemax_bind_vars_count = niltime_zone_aware_attributes = true
Jennifer::Config.configure do |conf|
conf.host = "localhost"
conf.user = "root"
conf.password = ""
conf.adapter = "mysql"
conf.db = "crystal"
end
Defined in:
jennifer/config.crConstant Summary
-
LOG_CONTEXT =
"db" -
Context name used for logger.
Constructors
-
.config : self
Returns default configuration object.
-
.configure : self
Returns default configuration object.
-
.instance : self
Default configuration object used by application.
- .new
-
.reset_config : Config
Reinitialize new configuration object with default values
Class Method Summary
-
.adapter
Delegates to
#adapter. -
.adapter=(value)
Delegates to
#adapter=. -
.allow_outdated_pending_migration
Delegates to
#allow_outdated_pending_migration. -
.allow_outdated_pending_migration=(value)
Delegates to
#allow_outdated_pending_migration=. -
.checkout_timeout
Delegates to
#checkout_timeout. -
.checkout_timeout=(value)
Delegates to
#checkout_timeout=. -
.command_shell
Delegates to
#command_shell. -
.command_shell=(value)
Delegates to
#command_shell=. -
.command_shell_sudo
Delegates to
#command_shell_sudo. -
.command_shell_sudo=(value)
Delegates to
#command_shell_sudo=. -
.configure(&)
Yields default configuration instance to block and validates it.
-
.db
Delegates to
#db. -
.db=(value)
Delegates to
#db=. -
.docker_container
Delegates to
#docker_container. -
.docker_container=(value)
Delegates to
#docker_container=. -
.docker_source_location
Delegates to
#docker_source_location. -
.docker_source_location=(value)
Delegates to
#docker_source_location=. -
.from_uri(uri)
Delegates call to #from_uri.
-
.host
Delegates to
#host. -
.host=(value)
Delegates to
#host=. -
.initial_pool_size
Delegates to
#initial_pool_size. -
.initial_pool_size=(value)
Delegates to
#initial_pool_size=. -
.local_time_zone
Delegates call to #local_time_zone.
-
.local_time_zone_name
Delegates to
#local_time_zone_name. -
.local_time_zone_name=(value)
Delegates to
#local_time_zone_name=. -
.logger
Delegates to
#:logger. -
.logger=(value)
Delegates to
#:logger=. -
.max_bind_vars_count
Delegates to
#:max_bind_vars_count. -
.max_bind_vars_count=(value)
Delegates to
#:max_bind_vars_count=. -
.max_idle_pool_size
Delegates to
#max_idle_pool_size. -
.max_idle_pool_size=(value)
Delegates to
#max_idle_pool_size=. -
.max_pool_size
Delegates to
#max_pool_size. -
.max_pool_size=(value)
Delegates to
#max_pool_size=. -
.migration_files_path
Delegates to
#migration_files_path. -
.migration_files_path=(value)
Delegates to
#migration_files_path=. -
.model_files_path
Delegates to
#model_files_path. -
.model_files_path=(value)
Delegates to
#model_files_path=. -
.password
Delegates to
#password. -
.password=(value)
Delegates to
#password=. -
.port
Delegates to
#port. -
.port=(value)
Delegates to
#port=. -
.read(*args, **opts)
Delegates call to #read.
- .read(*args, **opts, &)
-
.retry_attempts
Delegates to
#retry_attempts. -
.retry_attempts=(value)
Delegates to
#retry_attempts=. -
.retry_delay
Delegates to
#retry_delay. -
.retry_delay=(value)
Delegates to
#retry_delay=. -
.schema
Delegates to
#schema. -
.schema=(value)
Delegates to
#schema=. -
.skip_dumping_schema_sql
Delegates to
#skip_dumping_schema_sql. -
.skip_dumping_schema_sql=(value)
Delegates to
#skip_dumping_schema_sql=. -
.structure_folder
Delegates to
#structure_folder. -
.structure_folder=(value)
Delegates to
#structure_folder=. -
.structure_path : String
Delegates call to #structure_path.
-
.time_zone_aware_attributes
Delegates to
#time_zone_aware_attributes. -
.time_zone_aware_attributes=(value)
Delegates to
#time_zone_aware_attributes=. -
.user
Delegates to
#user. -
.user=(value)
Delegates to
#user=. -
.verbose_migrations
Delegates to
#verbose_migrations. -
.verbose_migrations=(value)
Delegates to
#verbose_migrations=.
Instance Method Summary
- #adapter : String
- #adapter=(adapter)
- #allow_outdated_pending_migration : Bool
- #allow_outdated_pending_migration=(allow_outdated_pending_migration)
- #checkout_timeout : Float64
- #checkout_timeout=(checkout_timeout)
- #command_shell : String
- #command_shell=(command_shell)
- #command_shell_sudo : Bool
- #command_shell_sudo=(command_shell_sudo)
- #db : String
- #db=(db)
- #docker_container : String
- #docker_container=(docker_container)
- #docker_source_location : String
- #docker_source_location=(docker_source_location)
-
#from_uri(uri : String)
Reads configuration properties from the given uri string.
-
#from_uri(uri : URI)
Reads configuration properties from the given uri.
-
#from_yaml(source)
Reads configuration properties from the given YAML source.
- #host : String
- #host=(host)
- #initial_pool_size : Int32
- #initial_pool_size=(initial_pool_size)
-
#local_time_zone : Time::Location
Returns local time zone.
- #local_time_zone_name : String
- #local_time_zone_name=(value : String)
- #local_time_zone_name=(local_time_zone_name)
-
#logger : Log
Loginstance. -
#logger=(logger : Log)
Loginstance. -
#max_bind_vars_count : Int32?
Maximum count of bind variables.
-
#max_bind_vars_count=(max_bind_vars_count : Int32?)
Maximum count of bind variables.
- #max_idle_pool_size : Int32
- #max_idle_pool_size=(max_idle_pool_size)
- #max_pool_size : Int32
- #max_pool_size=(max_pool_size)
-
#migration_failure_handler_method : Jennifer::Config::MigrationFailureHandler
Handler type for the failed migrations; default is
"none". - #migration_failure_handler_method=(value : MigrationFailureHandler)
- #migration_files_path : String
- #migration_files_path=(migration_files_path)
- #model_files_path : String
- #model_files_path=(model_files_path)
- #password : String
- #password=(password)
-
#pool_size
Returns maximum size of the pool.
-
#pool_size=(value : Int32)
Sets
#max_pool_size,#max_idle_pool_sizeand#initial_pool_sizeto the given value. - #port : Int32
- #port=(port)
-
#read(path : String, env : Symbol = :development)
Reads configurations from the file with given path for given env.
-
#read(path : String, env : String)
Reads configurations from the file with given path for given env.
-
#read(path : String, &)
Reads configurations from the file with given path.
- #retry_attempts : Int32
- #retry_attempts=(retry_attempts)
- #retry_delay : Float64
- #retry_delay=(retry_delay)
-
#schema : String
Defines postgres database schema name (postgres specific configuration).
- #schema=(schema)
- #skip_dumping_schema_sql : Bool
- #skip_dumping_schema_sql=(skip_dumping_schema_sql)
-
#structure_folder : String
Returns
schema.sqlfolder name. - #structure_folder=(structure_folder)
-
#structure_path : String
Return path to
structure.sqlfile. -
#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.
- #time_zone_aware_attributes=(time_zone_aware_attributes)
- #user : String
- #user=(user)
-
#verbose_migrations : Bool
Returns whether migrations should be performed in verbose mode.
- #verbose_migrations=(verbose_migrations)
Constructor Detail
Reinitialize new configuration object with default values
Class Method Detail
Delegates to #allow_outdated_pending_migration=.
Instance Method Detail
Reads configuration properties from the given uri string.
Jennifer::Config.from_uri("mysql://root:password@somehost:3306/some_database")
Maximum count of bind variables.
If nil - uses default adapter value.
Maximum count of bind variables.
If nil - uses default adapter value.
Handler type for the failed migrations; default is "none".
Sets #max_pool_size, #max_idle_pool_size and #initial_pool_size to the given value.
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)
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)
Reads configurations from the file with given path.
It is considered that all configuration properties are located at the root level.
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.
Returns whether migrations should be performed in verbose mode.
Default is true.