dry-auto_inject 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ca52f52195a91514c09f9a3e5c1e0a09d295eedb
4
- data.tar.gz: c9202a9e5de781177a5c2415c95959bf67c1d710
3
+ metadata.gz: 6f9eb1effcee4d7bd3a8741b9d66b736ec2a1254
4
+ data.tar.gz: f8401c55f988c919a09033e510fd58566bd76484
5
5
  SHA512:
6
- metadata.gz: d0f4d22af2854ee5546068ba0d1035c418adc4eaddde28812b5fd1063467d62169a4a42dff2999974bc25e09a2eca67cd48d775a4ec99b00fc0a85c260f2d1fb
7
- data.tar.gz: ba86065fc3bda9feda3623469ff01609b686dcbb383fb37dfb5bc5b17fb0c88ed625a7c41c58e708509b17ad4346980a995754f2592b1030acc37e51924ec356
6
+ metadata.gz: 6c6eea940b2c7c57137a737e3d66abd763ec2ff4e51725e7386bf15020efabe6c2485e412f0088fe54dccc16114914d0bada89d3a5a1c55e11da73f211b155e5
7
+ data.tar.gz: aac93975a6bbcd756108a72310d7f8995430bae11a97c867a3073e1503e95012cd177187d4aff0b4a9a4db6c988a3b21eb4f26074261eda5a0fdc450e56dacdb
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # 0.4.2 / 2016-10-10
2
+
3
+ ### Fixed
4
+
5
+ - Fixed issue where injectors for different containers could not be used on different classes in an inheritance hierarchy (timriley in [#31](https://github.com/dry-rb/dry-auto_inject/pull/31))
6
+
7
+ # 0.4.1 / 2016-08-14
8
+
9
+ ### Changed
10
+
11
+ - Loosened version dependency on dry-container (AMHOL)
12
+
1
13
  # 0.4.0 / 2016-07-26
2
14
 
3
15
  ### Added
@@ -7,14 +7,16 @@ module Dry
7
7
  class Args < Constructor
8
8
  private
9
9
 
10
- def define_new(klass)
11
- klass.class_eval <<-RUBY, __FILE__, __LINE__ + 1
12
- def self.new(*args)
13
- names = #{dependency_map.inspect}
14
- deps = names.values.map.with_index { |identifier, i| args[i] || container[identifier] }
10
+ def define_new
11
+ class_mod.class_exec(container, dependency_map) do |container, dependency_map|
12
+ define_method :new do |*args|
13
+ deps = dependency_map.to_h.values.map.with_index { |identifier, i|
14
+ args[i] || container[identifier]
15
+ }
16
+
15
17
  super(*deps, *args[deps.size..-1])
16
18
  end
17
- RUBY
19
+ end
18
20
  end
19
21
 
20
22
  def define_initialize(klass)
@@ -4,13 +4,7 @@ module Dry
4
4
  module AutoInject
5
5
  class Strategies
6
6
  class Constructor < Module
7
- ClassMethods = Class.new(Module) do
8
- def initialize(container)
9
- super()
10
- define_method(:container) { container }
11
- end
12
- end
13
-
7
+ ClassMethods = Class.new(Module)
14
8
  InstanceMethods = Class.new(Module)
15
9
 
16
10
  attr_reader :container
@@ -22,14 +16,14 @@ module Dry
22
16
  @container = container
23
17
  @dependency_map = DependencyMap.new(*dependency_names)
24
18
  @instance_mod = InstanceMethods.new
25
- @class_mod = ClassMethods.new(container)
19
+ @class_mod = ClassMethods.new
26
20
  end
27
21
 
28
22
  # @api private
29
23
  def included(klass)
30
24
  define_readers
31
25
 
32
- define_new(klass)
26
+ define_new
33
27
  define_initialize(klass)
34
28
 
35
29
  klass.send(:include, instance_mod)
@@ -47,7 +41,7 @@ module Dry
47
41
  self
48
42
  end
49
43
 
50
- def define_new(klass)
44
+ def define_new
51
45
  raise NotImplementedError, "must be implemented by a subclass"
52
46
  end
53
47
 
@@ -7,16 +7,16 @@ module Dry
7
7
  class Hash < Constructor
8
8
  private
9
9
 
10
- def define_new(_klass)
11
- class_mod.class_eval <<-RUBY, __FILE__, __LINE__ + 1
12
- def new(options = {})
13
- names = #{dependency_map.inspect}
14
- deps = names.each_with_object({}) { |(name, identifier), obj|
10
+ def define_new
11
+ class_mod.class_exec(container, dependency_map) do |container, dependency_map|
12
+ define_method :new do |options = {}|
13
+ deps = dependency_map.to_h.each_with_object({}) { |(name, identifier), obj|
15
14
  obj[name] = options[name] || container[identifier]
16
15
  }.merge(options)
16
+
17
17
  super(deps)
18
18
  end
19
- RUBY
19
+ end
20
20
  end
21
21
 
22
22
  def define_initialize(klass)
@@ -7,16 +7,16 @@ module Dry
7
7
  class Kwargs < Constructor
8
8
  private
9
9
 
10
- def define_new(_klass)
11
- class_mod.class_eval <<-RUBY, __FILE__, __LINE__ + 1
12
- def new(**args)
13
- names = #{dependency_map.inspect}
14
- deps = names.each_with_object({}) { |(name, identifier), obj|
10
+ def define_new
11
+ class_mod.class_exec(container, dependency_map) do |container, dependency_map|
12
+ define_method :new do |**args|
13
+ deps = dependency_map.to_h.each_with_object({}) { |(name, identifier), obj|
15
14
  obj[name] = args[name] || container[identifier]
16
15
  }.merge(args)
16
+
17
17
  super(**deps)
18
18
  end
19
- RUBY
19
+ end
20
20
  end
21
21
 
22
22
  def define_initialize(klass)
@@ -1,5 +1,5 @@
1
1
  module Dry
2
2
  module AutoInject
3
- VERSION = '0.4.1'.freeze
3
+ VERSION = '0.4.2'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry-auto_inject
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Solnica
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-14 00:00:00.000000000 Z
11
+ date: 2016-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-container
@@ -123,4 +123,3 @@ signing_key:
123
123
  specification_version: 4
124
124
  summary: Container-agnostic automatic constructor injection
125
125
  test_files: []
126
- has_rdoc: