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 +4 -4
- data/CHANGELOG.md +12 -0
- data/lib/dry/auto_inject/strategies/args.rb +8 -6
- data/lib/dry/auto_inject/strategies/constructor.rb +4 -10
- data/lib/dry/auto_inject/strategies/hash.rb +6 -6
- data/lib/dry/auto_inject/strategies/kwargs.rb +6 -6
- data/lib/dry/auto_inject/version.rb +1 -1
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f9eb1effcee4d7bd3a8741b9d66b736ec2a1254
|
4
|
+
data.tar.gz: f8401c55f988c919a09033e510fd58566bd76484
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
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)
|
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
|
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
|
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
|
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
|
11
|
-
class_mod.
|
12
|
-
|
13
|
-
|
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
|
-
|
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
|
11
|
-
class_mod.
|
12
|
-
|
13
|
-
|
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
|
-
|
19
|
+
end
|
20
20
|
end
|
21
21
|
|
22
22
|
def define_initialize(klass)
|
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.
|
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-
|
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:
|