lib/dry/auto_inject/strategies/constructor.rb in dry-auto_inject-0.8.0 vs lib/dry/auto_inject/strategies/constructor.rb in dry-auto_inject-0.9.0
- old
+ new
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-require 'dry/auto_inject/dependency_map'
+require "dry/auto_inject/dependency_map"
module Dry
module AutoInject
class Strategies
class Constructor < Module
@@ -13,10 +13,11 @@
attr_reader :dependency_map
attr_reader :instance_mod
attr_reader :class_mod
def initialize(container, *dependency_names)
+ super()
@container = container
@dependency_map = DependencyMap.new(*dependency_names)
@instance_mod = InstanceMethods.new
@class_mod = ClassMethods.new
end
@@ -35,21 +36,22 @@
end
private
def define_readers
+ readers = dependency_map.names.map { ":#{_1}" }
instance_mod.class_eval <<-RUBY, __FILE__, __LINE__ + 1
- attr_reader #{dependency_map.names.map { |name| ":#{name}" }.join(', ')}
+ attr_reader #{readers.join(", ")} # attr_reader :dep1, :dep2
RUBY
self
end
def define_new
- raise NotImplementedError, 'must be implemented by a subclass'
+ raise NotImplementedError, "must be implemented by a subclass"
end
- def define_initialize(klass)
- raise NotImplementedError, 'must be implemented by a subclass'
+ def define_initialize(_klass)
+ raise NotImplementedError, "must be implemented by a subclass"
end
end
end
end
end