lib/pennyworth/container.rb in pennyworth-15.0.3 vs lib/pennyworth/container.rb in pennyworth-15.1.0

- old
+ new

@@ -10,23 +10,26 @@ module Pennyworth # Provides a global gem container for injection into other objects. module Container extend Dry::Container::Mixin - register :configuration do + register :configuration, memoize: true do self[:defaults].add_loader(Etcher::Loaders::YAML.new(self[:xdg_config].active)) .then { |registry| Etcher.call registry } end - register :defaults do + register :defaults, memoize: true do Etcher::Registry.new(contract: Configuration::Contract, model: Configuration::Model) .add_loader(Etcher::Loaders::YAML.new(self[:defaults_path])) end - register(:defaults_path) { Pathname(__dir__).join("configuration/defaults.yml") } - register(:xdg_config) { Runcom::Config.new "pennyworth/configuration.yml" } - register(:specification) { Spek::Loader.call "#{__dir__}/../../pennyworth.gemspec" } - register(:kernel) { Kernel } - register(:http) { HTTP } - register(:logger) { Cogger.new formatter: :emoji } + register :specification, memoize: true do + Spek::Loader.call "#{__dir__}/../../pennyworth.gemspec" + end + + register(:defaults_path, memoize: true) { Pathname(__dir__).join("configuration/defaults.yml") } + register(:xdg_config, memoize: true) { Runcom::Config.new "pennyworth/configuration.yml" } + register(:logger, memoize: true) { Cogger.new formatter: :emoji } + register :http, HTTP + register :kernel, Kernel end end