container 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
  SHA1:
3
- metadata.gz: 45d84293e39dfe86c486d890b48ed9d7ef44bf51
4
- data.tar.gz: 1646d2ad850d63e71f664cfe7e2e521615131d0f
3
+ metadata.gz: bb9cc8e449bcfea00a468e9e4328c2da62f75b97
4
+ data.tar.gz: ffeaec2dd89b6819f512c9cb80c56bd78a643818
5
5
  SHA512:
6
- metadata.gz: ff1c7088cb7d02c317a31a6d9c055dfd8b8146f17377da6f96e14f1c207273b354bc48652c5fd5e2f3c0123c56a0b7eb718c38343ec4576fc03f20f34cc20d2c
7
- data.tar.gz: c58151925c1a972ca282e756e834c2cfbe4e6b0f0ef6bbcd98eaec085fad890eac5c14ed9011b0be84eb71eb40f666c6b5a71a58ac9814151e394755125cc1c6
6
+ metadata.gz: cad7e60e94f7d64ccf84ec2283032c9e5c18e59b875ccc2edd3cd2d802338ffb2f4651f2a2fa947bc9709f40c5484343718d4980d10b95efe73096afc91f91d4
7
+ data.tar.gz: eab9a86c9d49e06bf08b95b3794b553f3db7771472ccbe42382a5053dc89d8c4c638cfb754d6b64a92b8b1c5254af5ef1c4759ebc55de5421df30af3b98d68ed
@@ -1,3 +1,3 @@
1
1
  class Container
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
data/lib/container.rb CHANGED
@@ -29,9 +29,17 @@ class Container
29
29
 
30
30
  def [](key)
31
31
  if key.is_a?(Numeric)
32
- @array[key] || NullObject.new
32
+ safe @array[key]
33
33
  else
34
- @hash[key] || NullObject.new
34
+ safe @hash[key]
35
+ end
36
+ end
37
+
38
+ def safe(value)
39
+ if value.nil?
40
+ NullObject.new
41
+ else
42
+ value
35
43
  end
36
44
  end
37
45
 
@@ -71,7 +79,13 @@ class Container
71
79
  @hash[hash_key] = arguments.first
72
80
  else
73
81
  if @hash.keys.include?(hash_key)
74
- @hash[hash_key] || NullObject.new
82
+ return_value = @hash[hash_key]
83
+
84
+ if return_value.nil?
85
+ NullObject.new
86
+ else
87
+ return_value
88
+ end
75
89
  else
76
90
  NullObject.new
77
91
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: container
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
  - Joshua Arvin Lat