diftw 0.0.2 → 0.1.0

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: f25702b419277ffc7239774fb417f4c46dc86e40
4
- data.tar.gz: 43f53a75ff8a5d0aff5fdc2f2db2d0bbf1aa53de
3
+ metadata.gz: e2ca2e3bab186790bc0cb1330edf1060a0beed6f
4
+ data.tar.gz: 90572c316d59095be4846b9894fac598a9d2138e
5
5
  SHA512:
6
- metadata.gz: deeaf6569abd8027ff19f4e21f13949d12033270d4cccd233177e61d538c16772af952894abd2695d87d0e78b41c390d5496ed82df854f746ed8f4a3c0996a56
7
- data.tar.gz: 62218b71fae0e9753dbf25bcde9ee6fd8a01fe725703836691538d9df7f72dcfa88acb8e30e6728e1d6c3c0c78748b2b19a22e94541fea6962971d154c5d7bf4
6
+ metadata.gz: 524edb6efd5b288c937e4de007ab255922e44cb92ee07211bacbbb20ca4473497fdb12b564f2ed07b8114520ab7bad81ab86a7a407eeed06565a5f1944c6df79
7
+ data.tar.gz: 7cc3dace40aadf417ed602d6e376ab8b8198689bba652591581faa0b7bf58d1bdceeb3b7640ace5169b4ce0e5c68446ae5b7a42260ab2cb6e700617a55a1ea48
@@ -116,6 +116,26 @@ module DiFtw
116
116
  end
117
117
  end
118
118
 
119
+ #
120
+ # Injects dependencies into a specific, existing object.
121
+ #
122
+ # DI.inject_instance(obj, :foo, :bar)
123
+ #
124
+ # @param instance [Object] The object you wish to inject dependencies into
125
+ # @param dependencies [Symbol] All dependency names you want to inject.
126
+ #
127
+ def inject_instance(instance, *dependencies)
128
+ injector = self
129
+ instance.instance_eval do
130
+ dependencies.each do |dep|
131
+ define_singleton_method dep do
132
+ var = "@_diftw_#{dep}"
133
+ instance_variable_get(var) || instance_variable_set(var, injector[dep])
134
+ end
135
+ end
136
+ end
137
+ end
138
+
119
139
  private
120
140
 
121
141
  #
@@ -1,4 +1,4 @@
1
1
  module DiFtw
2
2
  # Library version
3
- VERSION = '0.0.2'.freeze
3
+ VERSION = '0.1.0'.freeze
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diftw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordan Hollinger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-02 00:00:00.000000000 Z
11
+ date: 2016-07-05 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A small dependency injection library for Ruby
14
14
  email: jordan.hollinger@gmail.com
@@ -46,3 +46,4 @@ signing_key:
46
46
  specification_version: 4
47
47
  summary: Dependency Injection For The Win!
48
48
  test_files: []
49
+ has_rdoc: