containable 2.3.0 → 2.5.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
- checksums.yaml.gz.sig +0 -0
- data/README.adoc +37 -8
- data/containable.gemspec +1 -1
- data/lib/containable/builder.rb +1 -1
- data/lib/containable/register.rb +3 -1
- data/lib/containable/test.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8691c7c7d23a740b711373bbfe355e7413e9350b1faf61c0953ff514279ebbce
|
|
4
|
+
data.tar.gz: 54f10746cda77ef1cd595df7f2b34c61f7436d4d73de5c74f8297dd785394d0a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d4f35a8ee054d8ac5a7dab8199071fe46432c3fb7a746f5f54785580062acaddc5f0261565815918a4373d87c9f80ee50c320a331f5a639cce80b3d0f809d85d
|
|
7
|
+
data.tar.gz: cb26cd7ca68edb7c1b717315171bd3592073bb182dc8906aff92920c8d8ef3dae0096202095cd156006b9282b19a8e2430857d49f184982fb46d51ddad22ef44
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/README.adoc
CHANGED
|
@@ -319,11 +319,16 @@ With the above, this means you can do the following:
|
|
|
319
319
|
|
|
320
320
|
[source,ruby]
|
|
321
321
|
----
|
|
322
|
-
# Merge
|
|
322
|
+
# Merge all dependencies.
|
|
323
|
+
Primary.merge Secondary
|
|
324
|
+
Primary["one.two"] # 2
|
|
325
|
+
Primary["three"] # 3
|
|
326
|
+
|
|
327
|
+
# Merge specific dependency.
|
|
323
328
|
Primary.merge Secondary, :three
|
|
324
329
|
Primary[:three] # 3
|
|
325
330
|
|
|
326
|
-
# Merge multiple dependencies.
|
|
331
|
+
# Merge multiple specific dependencies.
|
|
327
332
|
Primary.merge Secondary, "one.two", :three
|
|
328
333
|
Primary["one.two"] # 2
|
|
329
334
|
Primary[:three] # 3
|
|
@@ -333,7 +338,7 @@ Primary.merge Secondary, "one.two", :three, namespace: :top
|
|
|
333
338
|
Primary["top.one.two"] # 2
|
|
334
339
|
Primary["top.three"] # 3
|
|
335
340
|
|
|
336
|
-
# Merge as fresh (
|
|
341
|
+
# Merge as fresh (default is cache).
|
|
337
342
|
Primary.merge Secondary, "one.two", as: :fresh
|
|
338
343
|
|
|
339
344
|
# Merge with repeated messages since it answers itself.
|
|
@@ -391,6 +396,35 @@ Container.namespace(:one)
|
|
|
391
396
|
|
|
392
397
|
This is a convenience that should only be used in rare situations because defining your namespaces and associated dependencies using block syntax improves readability.
|
|
393
398
|
|
|
399
|
+
=== Keys
|
|
400
|
+
|
|
401
|
+
You can check if a key exists or not either by symbol or string. Example:
|
|
402
|
+
|
|
403
|
+
[source,ruby]
|
|
404
|
+
----
|
|
405
|
+
require "containable"
|
|
406
|
+
|
|
407
|
+
module Container
|
|
408
|
+
extend Containable
|
|
409
|
+
|
|
410
|
+
register :one, 1
|
|
411
|
+
register :two, 2
|
|
412
|
+
end
|
|
413
|
+
----
|
|
414
|
+
|
|
415
|
+
Given the above, this means you can do the following
|
|
416
|
+
|
|
417
|
+
[source,ruby]
|
|
418
|
+
----
|
|
419
|
+
Container.key? :one # true
|
|
420
|
+
Container.key? "one" # true
|
|
421
|
+
Container.key? :two # true
|
|
422
|
+
Container.key? :bogus # false
|
|
423
|
+
Container.keys # ["one", "two"]
|
|
424
|
+
----
|
|
425
|
+
|
|
426
|
+
💡 Prefer strings for keys, especially when using namespaces.
|
|
427
|
+
|
|
394
428
|
=== Enumeration
|
|
395
429
|
|
|
396
430
|
Enumeration is possible but limited. Given the following:
|
|
@@ -418,11 +452,6 @@ Container.each { |key, value| puts "#{key}=#{value}" }
|
|
|
418
452
|
Container.each_key { |key| puts "Key: #{key}" }
|
|
419
453
|
# Key: one
|
|
420
454
|
# Key: two
|
|
421
|
-
|
|
422
|
-
Container.key? :one # false
|
|
423
|
-
Container.key? "one" # true
|
|
424
|
-
|
|
425
|
-
Container.keys # ["one", "two"]
|
|
426
455
|
----
|
|
427
456
|
|
|
428
457
|
=== Freezing
|
data/containable.gemspec
CHANGED
data/lib/containable/builder.rb
CHANGED
data/lib/containable/register.rb
CHANGED
|
@@ -31,7 +31,9 @@ module Containable
|
|
|
31
31
|
alias register call
|
|
32
32
|
|
|
33
33
|
def merge other, *keys, namespace: nil, as: :cache
|
|
34
|
-
keys.
|
|
34
|
+
computed_keys = keys.empty? ? other.keys : keys
|
|
35
|
+
|
|
36
|
+
computed_keys.each { call [namespace, it].compact.join("."), other[it], as: }
|
|
35
37
|
self
|
|
36
38
|
end
|
|
37
39
|
|
data/lib/containable/test.rb
CHANGED
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: containable
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brooke Kuhlmann
|
|
@@ -90,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
90
90
|
- !ruby/object:Gem::Version
|
|
91
91
|
version: '0'
|
|
92
92
|
requirements: []
|
|
93
|
-
rubygems_version: 4.0.
|
|
93
|
+
rubygems_version: 4.0.20
|
|
94
94
|
specification_version: 4
|
|
95
95
|
summary: A thread-safe dependency injection container.
|
|
96
96
|
test_files: []
|
metadata.gz.sig
CHANGED
|
Binary file
|