diftw 0.3.1 → 0.4.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: 11ba99c68dd1b15fafd5d94f4894771637c61978
4
- data.tar.gz: c89aedd4e8a66677eeba1d83b6f767b95054f50f
3
+ metadata.gz: 003ba4d7dfddcf1130c2dcc1a82b398265af7c5e
4
+ data.tar.gz: 290586529ebe1c70de998696f182c06cd6251a07
5
5
  SHA512:
6
- metadata.gz: e47b532597878dfa9411e07112624e2d7f10a38bf357003c9a1ea5639b1552b8ec7eacab76b590a9b2fc5285b03ebcaa0901723e1cceb8e9e6707f7ace071926
7
- data.tar.gz: 05d52093ad104295682b173916b0d6541a11d66f1bf122b2523796d12e72f557d6544f1655ab35d8c2bd531ed30e97c0d9d3e9f927385178d4bfcfe0f2a67ff4
6
+ metadata.gz: 34f2a2827ee113f6e847318c2b5315d25109901727c0a743fff22b07953aae7fdf4efb1e0300658b5dd3a784101e008469cd90d88d50e79747101df09284b09e
7
+ data.tar.gz: 6ddc67b51453af2ccc8b29ae2712c06b27c704716af93f2435e5bfc12ea476792b0b1a6acfd194995f36c54e15c7e3aa3668a1938f320d0cd254bef9e9007f6b
data/README.md CHANGED
@@ -76,14 +76,14 @@ Lazy injection is usually fine. But if it isn't, use `inject!`:
76
76
 
77
77
  # Inject :baz as a class method
78
78
  class SomeClass
79
- DI.inject_instance self, :baz
79
+ extend DI.inject :baz
80
80
  end
81
81
  puts SomeClass.baz.message
82
82
  => 'Baz'
83
83
 
84
84
  # Inject :baz as a module method
85
85
  module SomeModule
86
- DI.inject_instance self, :baz
86
+ extend DI.inject :baz
87
87
  end
88
88
  puts SomeModule.baz.message
89
89
  => 'Baz'
data/lib/diftw/builder.rb CHANGED
@@ -45,6 +45,13 @@ module DiFtw
45
45
  end
46
46
  end
47
47
  end
48
+
49
+ def self.extended(base)
50
+ di_mod = self
51
+ base.singleton_class.class_eval do
52
+ include di_mod
53
+ end
54
+ end
48
55
  }.tap { |mod|
49
56
  mod.injector = Injector.new(parent: parent_injector)
50
57
  mod._diftw_dependencies = dependencies
@@ -125,10 +125,17 @@ module DiFtw
125
125
  #
126
126
  # Creates and returns a new Module which contains instance methods for all the dependencies you specified.
127
127
  # Simply include this module in your class, and all it's instances will have their dependencies injected.
128
+ # Or extend your class with this module, and your class *itself* will have the dependencies injected.
128
129
  #
129
130
  # class Widget
130
- # include DI.inject(:foo, :bar)
131
+ # include DI.inject :foo, :bar
131
132
  # end
133
+ # Widget.new.foo
134
+ #
135
+ # class Spline
136
+ # extend Di.inject :foo
137
+ # end
138
+ # Spline.foo
132
139
  #
133
140
  # @param dependencies [Symbol] All dependency names you want to inject.
134
141
  #
@@ -139,7 +146,7 @@ module DiFtw
139
146
  #
140
147
  # Injects dependencies into a specific, existing object.
141
148
  #
142
- # DI.inject_instance(obj, :foo, :bar)
149
+ # DI.inject_instance obj, :foo, :bar
143
150
  #
144
151
  # @param instance [Object] The object you wish to inject dependencies into
145
152
  # @param dependencies [Symbol] All dependency names you want to inject.
data/lib/diftw/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module DiFtw
2
2
  # Library version
3
- VERSION = '0.3.1'.freeze
3
+ VERSION = '0.4.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.3.1
4
+ version: 0.4.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-18 00:00:00.000000000 Z
11
+ date: 2016-07-25 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