leather-satchel 0.1.1 → 0.1.2
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68c8bcfc5d888b8e09e26b80e3f702a5471f7b634b43110b29bc9ba2526ab56a
|
4
|
+
data.tar.gz: ed09570840b1cb66583bcd751261cd58cbc6cad155109e368cea3715bfc1a8ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 988f088540dff38dfc1fa7b2ece2f7b6e3e57509b7107e33db1e968813411585107dd85d83965c6e0651111f6bd82ccee2713257a5237fc3f8db34d02e0762dc
|
7
|
+
data.tar.gz: 5b927d0d3d4e3fc3120d7068650986a39b632423f95d5e453b07e79cb2c220620ce9f33f1cf5dac412abc17f55a42de46e39cc159d0fbfa22e4f402b2159b478
|
data/lib/leather/satchel.rb
CHANGED
@@ -20,18 +20,26 @@ module Leather
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
# Checks if a given @key exists in the container
|
24
|
+
# @param key [String|Symbol] The name we are checking
|
25
|
+
# @return [Boolean]
|
26
|
+
def contain?(key)
|
27
|
+
@keys.key?(key)
|
28
|
+
end
|
29
|
+
|
23
30
|
# Inserts a service into the container under the name @key
|
24
|
-
# @param key [String|Symbol] The name of the service
|
25
|
-
# @param value [
|
31
|
+
# @param key [String|Symbol] The name of the value, service or factory
|
32
|
+
# @param value [Object] The object to store against @key
|
26
33
|
def []=(key, value)
|
27
34
|
@keys[key] = true
|
28
35
|
@values[key] = value
|
29
36
|
end
|
30
37
|
|
31
|
-
# Gets a service from the container
|
38
|
+
# Gets a value, service or factory from the container
|
32
39
|
# @param key [String|Symbol] The name of the service to look for
|
33
|
-
# @return [
|
34
|
-
# @
|
40
|
+
# @return [Object] The stored service value
|
41
|
+
# @raise [Error::UnknownIdentifierError] If the container doesn't contain
|
42
|
+
# the requested key
|
35
43
|
def [](key)
|
36
44
|
raise Error::UnknownIdentifierError, key unless @keys.key?(key)
|
37
45
|
|
@@ -52,6 +60,7 @@ module Leather
|
|
52
60
|
# Defines a factory service
|
53
61
|
# @param service [Proc]
|
54
62
|
# @return [Proc]
|
63
|
+
# @raise [Error::InvalidFactoryError] If the provided factory is not a Proc
|
55
64
|
def factory(service)
|
56
65
|
raise Error::InvalidFactoryError, service.class unless service.is_a?(Proc)
|
57
66
|
|
@@ -59,7 +68,7 @@ module Leather
|
|
59
68
|
service
|
60
69
|
end
|
61
70
|
|
62
|
-
# Deletes a stored service from the container if it exists
|
71
|
+
# Deletes a stored value, service or factory from the container if it exists
|
63
72
|
# @param key [String|Symbol]
|
64
73
|
def remove(key)
|
65
74
|
return unless @keys.key?(key)
|
@@ -3,10 +3,10 @@
|
|
3
3
|
module Leather
|
4
4
|
module Satchel
|
5
5
|
module Error
|
6
|
-
# Error
|
6
|
+
# Error raised if the requested identifier is not known by the container
|
7
7
|
class UnknownIdentifierError < StandardError
|
8
8
|
# UnknownIdentifierError constructor
|
9
|
-
# @param identifier [String]
|
9
|
+
# @param identifier [String|Symbol]
|
10
10
|
def initialize(identifier)
|
11
11
|
message = "Unknown service identifier #{identifier}"
|
12
12
|
super(message)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: leather-satchel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christopher Birmingham
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|