scorpion-ioc 0.5.2 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/lib/scorpion/dependency.rb +6 -1
- data/lib/scorpion/rails/job.rb +1 -3
- data/lib/scorpion/rails/mailer.rb +1 -3
- data/lib/scorpion/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6428d2f5e0abe49e6c16b290662aecb892a82fe6
|
4
|
+
data.tar.gz: 8f0887e737d14eba6f16783a351e234282297d5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20714b9c65809825c63350841a0099a7d3962eb8c40a17af38758a817ebfc924c8a1babf3d9dad03710ba188f4f942f4b749f8f840b89d90f256479d882c1244
|
7
|
+
data.tar.gz: 77282f171a0e64132832256138d0844163bb9fd5c142a98f372d93a31165d67e7526984f92dfe88b354330b7a1751326e9eb6f4763b5597a00d9b3ee27475e65
|
data/README.md
CHANGED
@@ -49,7 +49,7 @@ make them overridable, or just use module mixins.
|
|
49
49
|
|
50
50
|
Most of these counter arguments focus on testing, and given how easy it is to
|
51
51
|
mock objects in Ruby, you don't really need a framework. If testing were the
|
52
|
-
only virtue they'd be spot on. Despite
|
52
|
+
only virtue they'd be spot on. Despite its virtues DI doesn't come without its
|
53
53
|
own problems. However for larger projects that you expect to be long-lived, a DI
|
54
54
|
framework may help manage the complexity.
|
55
55
|
|
@@ -144,7 +144,7 @@ end
|
|
144
144
|
```
|
145
145
|
|
146
146
|
Here the dependency is clearly defined - and even creates accessors for getting
|
147
|
-
and setting the weapon. When a Hunter is created
|
147
|
+
and setting the weapon. When a Hunter is created its dependencies are also
|
148
148
|
created - and any of their dependencies and so on. Usage is equally simple
|
149
149
|
|
150
150
|
```ruby
|
@@ -219,7 +219,7 @@ end
|
|
219
219
|
zoo = scorpion.fetch Zoo
|
220
220
|
zoo.keeper # => an instance of a Zoo::Keeper
|
221
221
|
zoo.vet? # => false it hasn't been hunted down yet
|
222
|
-
zoo.vet # => an
|
222
|
+
zoo.vet # => an instance of a Zoo::Vet
|
223
223
|
zoo.keeper.lunch # => an instance of FastFood
|
224
224
|
```
|
225
225
|
|
@@ -405,7 +405,7 @@ Scorpion allows you to capture dependency and feed the same instance to everyone
|
|
405
405
|
asks for a matching dependency.
|
406
406
|
|
407
407
|
DI singletons are different then global singletons in that each scorpion can
|
408
|
-
have a unique instance of the class that it shares with all of
|
408
|
+
have a unique instance of the class that it shares with all of its objects. This
|
409
409
|
allows, for example, global variable like support per-request without polluting
|
410
410
|
the global namespace or dealing with thread concurrency issues.
|
411
411
|
|
@@ -429,7 +429,7 @@ use `share`.
|
|
429
429
|
|
430
430
|
A scorpion nest is where a mother scorpion lives and conceives young -
|
431
431
|
duplicates of the mother but maintaining their own state. The scorpion nest is
|
432
|
-
used by the Rails integration to give each request
|
432
|
+
used by the Rails integration to give each request its own scorpion.
|
433
433
|
|
434
434
|
All preparation performed by the mother is shared with all the children it
|
435
435
|
conceives so that configuration is established when the application starts.
|
data/lib/scorpion/dependency.rb
CHANGED
@@ -103,7 +103,12 @@ module Scorpion
|
|
103
103
|
Scorpion::Dependency::BuilderDependency.new( contract, traits, with )
|
104
104
|
elsif block_given?
|
105
105
|
Scorpion::Dependency::BuilderDependency.new( contract, traits, builder )
|
106
|
-
|
106
|
+
|
107
|
+
# Allow a Class/Module to define a #create method that will resolve
|
108
|
+
# and return an instance of itself. Do not automatically inherit the
|
109
|
+
# #create method so only consider it if the owner of the method is the
|
110
|
+
# contract itself.
|
111
|
+
elsif contract.respond_to?( :create ) && contract.singleton_methods( false ).include?( :create )
|
107
112
|
Scorpion::Dependency::BuilderDependency.new( contract, traits ) do |hunt,*args,**dependencies,&block|
|
108
113
|
if dependencies.present?
|
109
114
|
contract.create hunt, *args, **dependencies, &block
|
data/lib/scorpion/rails/job.rb
CHANGED
@@ -11,9 +11,7 @@ module Scorpion
|
|
11
11
|
# Setup dependency injection
|
12
12
|
base.send :include, Scorpion::Object
|
13
13
|
base.send :include, Scorpion::Rails::Nest
|
14
|
-
base.send :around_perform
|
15
|
-
job.send :with_scorpion, &block
|
16
|
-
end
|
14
|
+
base.send :around_perform, :with_scorpion
|
17
15
|
|
18
16
|
super
|
19
17
|
end
|
@@ -11,9 +11,7 @@ module Scorpion
|
|
11
11
|
# Setup dependency injection
|
12
12
|
base.send :include, Scorpion::Object
|
13
13
|
base.send :include, Scorpion::Rails::Nest
|
14
|
-
base.send :around_filter
|
15
|
-
mailer.with_scorpion &block
|
16
|
-
end
|
14
|
+
base.send :around_filter, :with_scorpion
|
17
15
|
|
18
16
|
super
|
19
17
|
end
|
data/lib/scorpion/version.rb
CHANGED