canfig 0.0.9 → 0.0.10

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: cb0af652bc6aced0a5a7be703c93267bbef555c28f821c565c9c5b14f93b6d20
4
- data.tar.gz: cb3541d3ca774f5f7a331f75238ecef6231b62be3776b50ae52cac3b12182c6b
3
+ metadata.gz: 70fda774961e755691e8a4783071ce7298b694933c4db7b2227b8563c1afeae7
4
+ data.tar.gz: 87b8c4825bf0e9b3e8d03a97c5e2f3c0643e67cca4703f48eea4e44411304959
5
5
  SHA512:
6
- metadata.gz: aab3a3c345efea85b20c75e8aec11ccd62baab19e8dcfa5b5870406a2731e6894311a21273b10cfea3476f037185b300e862e027a19bf8314fbb9300054d2b78
7
- data.tar.gz: ebc54005799b649dbecc527bd30f6bbad0149ad4fc022b2998323b0fe6b7888df12ffc1050a9884caee2ee14e30093f315408ed08e657b4e3a8dc657e3449459
6
+ metadata.gz: 4ad137615641ae7ca8c67716720f34c3e4068e92117887eb1f9fe786aa33175da0457d128236477fef4052391106b276ce4b8e278fd8825879e2139ea3d0972f
7
+ data.tar.gz: 2811ee9abc222199f3fdba1b5398f4e938891faf756f24080c7514e6c853668ea56c47b73847b04922d72f59bac3262f5479ba69d7da040a106d674fe5f7a124
@@ -37,8 +37,10 @@ module Canfig
37
37
  end
38
38
 
39
39
  def env(key, default=nil, &block)
40
- val = ENV.fetch(key.to_s.underscore.upcase, default, &block)
41
- val && ENV.key?(val) ? env(val, default, &block) : val
40
+ @state[key] ||= begin
41
+ val = ENV.fetch(key.to_s.underscore.upcase, default, &block)
42
+ val && ENV.key?(val) ? env(val, default, &block) : val
43
+ end
42
44
  end
43
45
 
44
46
  def clear(*keys)
@@ -53,7 +55,7 @@ module Canfig
53
55
 
54
56
  def get(key, default=nil, &block)
55
57
  raise NoMethodError, "undefined method `#{key.to_s}' for #{self.to_s}" unless allowed?(key)
56
- @state[key] ||= env(key, default, &block)
58
+ @state[key] || (block_given? ? yield : default)
57
59
  end
58
60
 
59
61
  def [](key)
@@ -7,8 +7,8 @@ module Canfig
7
7
  super(**options, &block)
8
8
  end
9
9
 
10
- def set(key, val)
11
- raise NotImplementedError, "You cannot set values on a Canfig::EnvConfig"
10
+ def get(key, default=nil, &block)
11
+ super || env(key, default, &block)
12
12
  end
13
13
 
14
14
  def env(key, default=nil, &block)
@@ -1,3 +1,3 @@
1
1
  module Canfig
2
- VERSION = '0.0.9'
2
+ VERSION = '0.0.10'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canfig
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Rebec