leather-satchel 0.1.1 → 0.1.2

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
  SHA256:
3
- metadata.gz: 9c531f034f0e6cf6c139f9eaa51b5280df321a2ce8ec370cc5f5429a1cfb9402
4
- data.tar.gz: 0a05b7cb604130890d73f43db41b8b1459b4b588f2e375cb99c5afbf4b94fcc9
3
+ metadata.gz: 68c8bcfc5d888b8e09e26b80e3f702a5471f7b634b43110b29bc9ba2526ab56a
4
+ data.tar.gz: ed09570840b1cb66583bcd751261cd58cbc6cad155109e368cea3715bfc1a8ad
5
5
  SHA512:
6
- metadata.gz: d8b4a4a05edab3a71ce914619af0d35b73348d51e1914eb763cd816deeeb4f8218b9110308d934b20f12f1230737b09742d93519e9399eaa3ddd923f4ef077c7
7
- data.tar.gz: 65d7be73ad4b1bcf280ac3554df72cab3847432744257a66ae11b0e591f8b6ac2dd2cdf076a946af3758ce51cdcbc607e345381d26134c2fc1acfbe6099ed698
6
+ metadata.gz: 988f088540dff38dfc1fa7b2ece2f7b6e3e57509b7107e33db1e968813411585107dd85d83965c6e0651111f6bd82ccee2713257a5237fc3f8db34d02e0762dc
7
+ data.tar.gz: 5b927d0d3d4e3fc3120d7068650986a39b632423f95d5e453b07e79cb2c220620ce9f33f1cf5dac412abc17f55a42de46e39cc159d0fbfa22e4f402b2159b478
@@ -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 [Any] The value of the container
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 [Any] The stored service value
34
- # @throw Error::UnknownIdentifierError
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,6 +3,7 @@
3
3
  module Leather
4
4
  module Satchel
5
5
  module Error
6
+ # Error raised if the provided factory is not the correct type
6
7
  class InvalidFactoryError < StandardError
7
8
  # InvalidFactoryError constructor
8
9
  # @param type [String]
@@ -3,10 +3,10 @@
3
3
  module Leather
4
4
  module Satchel
5
5
  module Error
6
- # Error to be raised if an identifier is unknown
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)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Leather
4
4
  module Satchel
5
- VERSION = '0.1.1'
5
+ VERSION = '0.1.2'
6
6
  end
7
7
  end
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.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-14 00:00:00.000000000 Z
11
+ date: 2020-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler