lib/dry/system/auto_registrar.rb in dry-system-0.20.0 vs lib/dry/system/auto_registrar.rb in dry-system-0.21.0
- old
+ new
@@ -27,29 +27,17 @@
end
end
# @api private
def call(component_dir)
- components(component_dir).each do |component|
+ component_dir.each_component do |component|
next unless register_component?(component)
container.register(component.key, memoize: component.memoize?) { component.instance }
end
end
private
-
- def components(component_dir)
- files(component_dir.full_path).map { |file_path|
- component_dir.component_for_path(file_path)
- }
- end
-
- def files(dir)
- raise ComponentDirNotFoundError, dir unless Dir.exist?(dir)
-
- Dir["#{dir}/**/#{RB_GLOB}"].sort
- end
def register_component?(component)
!container.registered?(component.key) && component.auto_register?
end
end