hypo 0.3.0 → 0.4.0
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/lib/hypo/container.rb +6 -3
- data/lib/hypo/{component.rb → lazy_component.rb} +1 -1
- data/lib/hypo/simple_component.rb +17 -0
- data/lib/hypo/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16e2327263264e9d87d5a3bbbcfb69639f9d8a97
|
4
|
+
data.tar.gz: 2c188346ea7e3ebf43420daff2ce41cdbc10bba7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32e602357537e0c5936ea8e3df4b2ec7cae3929e9be97566856ee282b6464c9b6958597e23bf29b4713e8276d94f11edcbbe29c729088875bba43cc30cb4bf8c
|
7
|
+
data.tar.gz: 4f66a7f5368809046dcdd4218798c3ad5fad65612c319511f8926d26ec2dfa0b7eee182ff8d8a584efc5a26b62d3440df325a08da3a9b03913438ca036f88000
|
data/lib/hypo/container.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'hypo/container_error'
|
2
|
-
require 'hypo/
|
2
|
+
require 'hypo/lazy_component'
|
3
|
+
require 'hypo/simple_component'
|
3
4
|
|
4
5
|
module Hypo
|
5
6
|
class Container
|
@@ -7,8 +8,10 @@ module Hypo
|
|
7
8
|
@components = {}
|
8
9
|
end
|
9
10
|
|
10
|
-
def register(
|
11
|
-
|
11
|
+
def register(item, name = nil)
|
12
|
+
type = item.is_a?(Class) ? LazyComponent : SimpleComponent
|
13
|
+
component = type.new(item, self, name)
|
14
|
+
|
12
15
|
if @components.key?(component.name)
|
13
16
|
raise ContainerError, "Component of type \"#{component.type.to_s}\" has already been registered"
|
14
17
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Hypo
|
2
|
+
class SimpleComponent
|
3
|
+
attr_reader :name
|
4
|
+
|
5
|
+
def initialize(object, container, name)
|
6
|
+
raise ContainerError, 'Registered object should have a name' if name.nil?
|
7
|
+
|
8
|
+
@object = object
|
9
|
+
@name = name
|
10
|
+
@container = container
|
11
|
+
end
|
12
|
+
|
13
|
+
def instance
|
14
|
+
@object
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/hypo/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hypo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Kalinkin
|
@@ -70,9 +70,10 @@ files:
|
|
70
70
|
- bin/setup
|
71
71
|
- hypo.gemspec
|
72
72
|
- lib/hypo.rb
|
73
|
-
- lib/hypo/component.rb
|
74
73
|
- lib/hypo/container.rb
|
75
74
|
- lib/hypo/container_error.rb
|
75
|
+
- lib/hypo/lazy_component.rb
|
76
|
+
- lib/hypo/simple_component.rb
|
76
77
|
- lib/hypo/version.rb
|
77
78
|
homepage: https://github.com/cylon-v/hypo
|
78
79
|
licenses:
|