module Athena::Config

Overview

Athena's Config component contains common types for configuring components/features, and managing ACF::Parameters.

Getting Started

If using this component within the [Athena Framework][Athena::Framework], it is already installed and required for you. Otherwise, if using it outside of the framework, you will first need to add it as a dependency:

dependencies:
  athena-config:
    github: athena-framework/config
    version: ~> 0.3.0

Then run shards install, being sure to require it via require "athena-config".

From here, checkout the manual for some additional information on how to use it both within and outside of the framework.

INFO: DI parameter injection requires the [Athena::DependencyInjection][] component as well.

Defined in:

annotation_configurations.cr
athena-config.cr

Constant Summary

VERSION = "0.3.3"

Class Method Summary

Macro Summary

Class Method Detail

def self.config : ACF::Base #

Returns the configured ACF::Base instance. The instance is a lazily initialized singleton.

ACF.load_configuration may be redefined to change how the configuration object is provided; e.g. create it from a YAML or JSON configuration file. See the external documentation for more information.


[View source]
def self.parameters : ACF::Parameters #

Returns the configured ACF::Parameters instance. The instance is a lazily initialized singleton.

ACF.load_parameters may be redefined to change how the parameters object is provided; e.g. create it from a YAML or JSON configuration file. See the external documentation for more information.


[View source]

Macro Detail

macro configuration_annotation(name, *args, &) #

Registers a configuration annotation with the provided name. Defines a configuration record with the provided args, if any, that represents the possible arguments that the annotation accepts. May also be used with a block to add custom methods to the configuration record.

Example

# Defines an annotation without any arguments.
ACF.configuration_annotation Secure

# Defines annotation with a required and optional argument.
# The default value will be used if that key isn't supplied in the annotation.
ACF.configuration_annotation SomeAnn, id : Int32, debug : Bool = true

# A block can be used to define custom methods on the configuration object.
ACF.configuration_annotation CustomAnn, first_name : String, last_name : String do
  def name : String
    "#{@first_name} #{@last_name}"
  end
end

NOTE The logic to actually do the resolution of the annotations must be handled in the owning shard. Athena::Config only defines the common logic that each implementation can use. See ACF::AnnotationConfigurations for more information.


[View source]