arcanus 0.5.0 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3084d4e42b743d23e52304af98742faed85f52a5
4
- data.tar.gz: d898161ecdb772ddbd97c476528f537a812e1235
3
+ metadata.gz: 4f691ad3164c5ba4a261d2d974d4095b480c739d
4
+ data.tar.gz: 22682f983ddb043dcf11e01abd60ee76ebe2fae2
5
5
  SHA512:
6
- metadata.gz: 63f8ee7cb795a80a52a7398b644b111902a23deedf43f314864c118578abb45cf5e6995902f7a95b0278f345946659063932a96366f3fe224338b07ebee059fe
7
- data.tar.gz: 627f3f7b281e70ec7b0328c33be30bca912f16439d420be27d490c6adff85a0b4772928b7d47b366b1d0dcf13e5d1b14977cad3856e4ac16d33ba591aed5c2f5
6
+ metadata.gz: ee13797a980e9f9a2afd541884a3d814a2e4348aa953657ddb29ec6684f9bdb68a5df5d00dea7c07c56284d7c565f52486870fc3e2b7b81baf555f69d449805b
7
+ data.tar.gz: 168b42e29bca5d5b8c6280880e074316802e1c936f41a7f45011ec141f0ecb8cc007af7a91b7ebe9e57aec24f8670c03b126a312c16fdbc279606edb303a0f5d
@@ -21,39 +21,28 @@ module Arcanus
21
21
  # @param key [String]
22
22
  # @return [Object]
23
23
  def [](key)
24
- @hash[key]
25
- end
26
-
27
- # Fetch key from the chest as if it were a hash.
28
- def fetch(*args)
29
- @hash.fetch(*args)
30
- end
31
-
32
- # Returns the contents of the chest as a hash.
33
- def contents
34
- @hash
35
- end
36
-
37
- # Provides access to chest items using regular method calls instead of hash
38
- # accesses.
39
- def method_missing(method_sym, *)
40
- method_name = method_sym.to_s
41
- if @hash.key?(method_name)
42
- value = @hash[method_name]
24
+ if @hash.key?(key)
25
+ value = @hash[key]
43
26
  if value.is_a?(Hash)
44
- Item.new(value, [method_name])
27
+ Item.new(value, [key])
45
28
  else
46
29
  value
47
30
  end
48
31
  else
49
32
  raise KeyError,
50
- "Key '#{method_name}' does not exist in this Arcanus chest",
33
+ "Key '#{key}' does not exist in this Arcanus chest",
51
34
  caller
52
35
  end
53
36
  end
54
37
 
55
- def respond_to?(method_sym, include_private = false)
56
- @hash.key?(method_sym.to_s) || super
38
+ # Fetch key from the chest as if it were a hash.
39
+ def fetch(*args)
40
+ @hash.fetch(*args)
41
+ end
42
+
43
+ # Returns the contents of the chest as a hash.
44
+ def contents
45
+ @hash
57
46
  end
58
47
 
59
48
  # Set value for the specified key path.
@@ -189,40 +178,33 @@ module Arcanus
189
178
  # Helper class for returning contents nested hashes, exposing helpers to
190
179
  # access them via method calls.
191
180
  class Item
192
- def initialize(hash, prefix = [])
181
+ def initialize(hash, prefix)
193
182
  @hash = hash
194
183
  @prefix = prefix
195
184
  end
196
185
 
197
- def method_missing(method_sym, *)
198
- method_name = method_sym.to_s
199
- if @hash.key?(method_name)
200
- value = @hash[method_name]
186
+ # Access the item as if it were a hash.
187
+ #
188
+ # This will raise an error if the key does not exist, however.
189
+ #
190
+ # @param key [String]
191
+ # @return [Object]
192
+ def [](key)
193
+ if @hash.key?(key)
194
+ value = @hash[key]
201
195
  if value.is_a?(Hash)
202
- Item.new(value, @prefix + [method_name])
196
+ Item.new(value, @prefix + [key])
203
197
  else
204
198
  value
205
199
  end
206
200
  else
207
- key_name = "#{@prefix.join('.')}.#{method_name}"
201
+ key_name = "#{@prefix.join('.')}.#{key}"
208
202
  raise KeyError,
209
203
  "Key '#{key_name}' does not exist in this Arcanus chest",
210
204
  caller
211
205
  end
212
206
  end
213
207
 
214
- def respond_to?(method_sym, include_private = false)
215
- @hash.key?(method_sym.to_s) || super
216
- end
217
-
218
- # Access the item as if it were a hash.
219
- #
220
- # @param key [String]
221
- # @return [Object]
222
- def [](key)
223
- @hash[key]
224
- end
225
-
226
208
  # Fetch key from the chest as if it were a hash.
227
209
  def fetch(*args)
228
210
  @hash.fetch(*args)
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Defines the gem version.
4
4
  module Arcanus
5
- VERSION = '0.5.0'.freeze
5
+ VERSION = '0.6.0'.freeze
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arcanus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane da Silva