sinject 0.2.3 → 0.2.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/Gemfile +0 -1
- data/README.md +23 -22
- data/lib/sinject/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db6745bbf4a6fd9f3355de4ebdc1b1a8ff9baac2
|
4
|
+
data.tar.gz: 5e595fc791ed9ed491df2cc49359cf821641f6ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88674605b4a9265fa8e2835fc4dd4dadb02be1535feff9ae5f863fcd799563483753f8056505fb7bba2d282e901fab766bb23a08a36100d10b496efcc2f4611b
|
7
|
+
data.tar.gz: f7d5be771710b45ba3d3fa6dc5aa9674faf96037a60d4cda3e850572deff3657d71eb6f2d739fcc1255de7330592e5550a7438e12f4a05ecd0dbabf6cde13297
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -54,6 +54,29 @@ Dependencies that require custom initialization can be registered with an initia
|
|
54
54
|
|
55
55
|
Dependencies with a custom initialization block must return an object of the registered dependency class type, if an unexpected instance is returned then Sinject will raise a `DependencyInitializeException`.
|
56
56
|
|
57
|
+
**Assigning dependencies**
|
58
|
+
|
59
|
+
To assign a dependency to an object you need to add the dependency attribute to the class and specify the symbol key that was used to register the dependency with the SinjectContainer:
|
60
|
+
|
61
|
+
class MySqlCountryRepository
|
62
|
+
|
63
|
+
dependency :cache_store
|
64
|
+
|
65
|
+
.....
|
66
|
+
end
|
67
|
+
|
68
|
+
class CountryController < ActionController::Base
|
69
|
+
|
70
|
+
dependency :country_repository
|
71
|
+
|
72
|
+
.....
|
73
|
+
end
|
74
|
+
|
75
|
+
Sinject will then inject the registered dependency to that object and it will be accessible via the dependency key:
|
76
|
+
|
77
|
+
country_controller.country_repository.cache_store
|
78
|
+
|
79
|
+
|
57
80
|
**Dependency Contracts**
|
58
81
|
|
59
82
|
Dependency contracts can be defined to validate registered dependencies are valid for the task they are being registered for. *(If you are familiar with other type based languages then you can think of this as a kind of Interface)*
|
@@ -99,28 +122,6 @@ To load valid dependency groups the following method needs to be called from the
|
|
99
122
|
|
100
123
|
container.load_groups
|
101
124
|
|
102
|
-
**Assigning dependencies**
|
103
|
-
|
104
|
-
To assign a dependency to an object you need to add the dependency attribute to the class and specify the symbol key that was used to register the dependency with the SinjectContainer:
|
105
|
-
|
106
|
-
class MySqlCountryRepository
|
107
|
-
|
108
|
-
dependency :cache_store
|
109
|
-
|
110
|
-
.....
|
111
|
-
end
|
112
|
-
|
113
|
-
class CountryController < ActionController::Base
|
114
|
-
|
115
|
-
dependency :country_repository
|
116
|
-
|
117
|
-
.....
|
118
|
-
end
|
119
|
-
|
120
|
-
Sinject will then inject the registered dependency to that object and it will be accessible via the dependency key:
|
121
|
-
|
122
|
-
country_controller.country_repository.cache_store
|
123
|
-
|
124
125
|
|
125
126
|
## Development
|
126
127
|
|
data/lib/sinject/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinject
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vaughan britton
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|