Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions config/initializers/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ def configuration_filename
end
private :configuration_filename

# When invoked, this method will return a Hashie::Mash object that contains all the settings loaded from
# the YAML file.
# For example, you can access settings like `Settings.pipelines`, `Settings.purposes`, etc.
def instance # rubocop:todo Metrics/AbcSize
# @instance is a Hashie::Mash object that contains all the settings loaded from the YAML file.
# It allows for method calls like Settings.pipelines, Settings.purposes, etc.
return @instance if @instance.present?

# Ideally we'd do Hashie::Mash.load(File.read(configuration_filename)) here
Expand All @@ -23,6 +28,8 @@ def instance # rubocop:todo Metrics/AbcSize

# To view a list of pipeline groups and respective pipelines:
# e.g. Settings.pipelines.group_by(&:pipeline_group).transform_values { |pipelines| pipelines.map(&:name) }

# This line has specifically been set to customise the behaviour of loading the pipelines.
@instance.pipelines = ConfigLoader::PipelinesLoader.new.pipelines

@instance
Expand All @@ -38,6 +45,9 @@ def instance # rubocop:todo Metrics/AbcSize
# rubocop:enable Style/StderrPuts
end

# This line is making it possible to access configuration using
# the Settings.<config> syntax. For example, Settings.pipelines, Settings.purposes, etc.
# It delegates all method calls to the Mash (which is @instance here).
delegate_missing_to :instance

def reinitialize
Expand Down