hypo 0.8.3 → 0.8.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hypo/container.rb +13 -5
- data/lib/hypo/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: fd560fba4f09760c2f3ee4bf31f4b1f5402d3b01
|
4
|
+
data.tar.gz: 933cdf609ead65b7e544d0d95e53ce9c6f7bd36c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 707c9606de4cf20ab52b3dda040186efea9accefa83d519b1c1702582f6f27f2b7667cc913310b92fadac5e87dcf272068f40ebf8aebe55a73330e3619f9f14c
|
7
|
+
data.tar.gz: a7c6965b37b398284c19afbbf9fd0ce37dc914d52555a6e357d5d2eaa1bceb04295b5868a1ff119df1556887a050eb362f70e2f03be9187447954d0bd418bb6a
|
data/lib/hypo/container.rb
CHANGED
@@ -7,7 +7,7 @@ require 'hypo/lifetime/scope'
|
|
7
7
|
|
8
8
|
module Hypo
|
9
9
|
class Container
|
10
|
-
attr_reader :lifetimes
|
10
|
+
attr_reader :lifetimes, :components
|
11
11
|
|
12
12
|
def initialize
|
13
13
|
@components = {}
|
@@ -36,6 +36,10 @@ module Hypo
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def register_instance(item, name)
|
39
|
+
if %w(attrs attributes).include? name
|
40
|
+
raise ContainerError, "Name \"#{name}\" is reserved by Hypo container please use another variant."
|
41
|
+
end
|
42
|
+
|
39
43
|
@mutex.synchronize do
|
40
44
|
instance = Instance.new(item, self, name)
|
41
45
|
@components[name] = instance
|
@@ -45,11 +49,15 @@ module Hypo
|
|
45
49
|
end
|
46
50
|
|
47
51
|
def resolve(name)
|
48
|
-
|
49
|
-
|
50
|
-
|
52
|
+
if %w(attrs attributes).include? name
|
53
|
+
{}
|
54
|
+
else
|
55
|
+
unless @components.key?(name)
|
56
|
+
raise ContainerError, "Component with name \"#{name}\" is not registered"
|
57
|
+
end
|
51
58
|
|
52
|
-
|
59
|
+
@components[name].instance
|
60
|
+
end
|
53
61
|
end
|
54
62
|
|
55
63
|
def add_lifetime(lifetime, name)
|
data/lib/hypo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hypo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Kalinkin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|