lib/dry/system/booter.rb in dry-system-0.12.0 vs lib/dry/system/booter.rb in dry-system-0.13.0

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + require 'dry/system/components/bootable' require 'dry/system/errors' require 'dry/system/constants' require 'dry/system/lifecycle' require 'dry/system/booter/component_registry' @@ -47,13 +49,11 @@ # @api private def load_component(path) identifier = Pathname(path).basename(RB_EXT).to_s.to_sym - unless components.exists?(identifier) - require path - end + require path unless components.exists?(identifier) self end # @api private @@ -106,11 +106,11 @@ end # @api private def stop(name_or_component) call(name_or_component) do |component| - raise ComponentNotStartedError.new(name_or_component) unless booted.include?(component) + raise ComponentNotStartedError, name_or_component unless booted.include?(component) component.stop booted.delete(component) yield if block_given? @@ -118,13 +118,11 @@ end # @api private def call(name_or_component) with_component(name_or_component) do |component| - unless component - raise ComponentFileMismatchError.new(name, registered_booted_keys) - end + raise ComponentFileMismatchError.new(name, registered_booted_keys) unless component yield(component) if block_given? component end @@ -151,16 +149,19 @@ yield(component) end # @api private def require_boot_file(identifier) - boot_file = boot_files.detect { |path| Pathname(path).basename(RB_EXT).to_s == identifier.to_s } + boot_file = boot_files.detect { |path| + Pathname(path).basename(RB_EXT).to_s == identifier.to_s + } + require boot_file if boot_file end # @api private def boot_files - Dir["#{path}/**/#{RB_GLOB}"] + ::Dir["#{path}/**/#{RB_GLOB}"].sort end # @api private def boot_dependency(component) boot_file = boot_file(component)