Class: Suzanne::EnvReader
- Inherits:
-
Object
- Object
- Suzanne::EnvReader
show all
- Defined in:
- lib/suzanne/env_reader.rb
Defined Under Namespace
Classes: MissingKey
Instance Method Summary
collapse
Constructor Details
#initialize(config_hash) ⇒ EnvReader
ENV takes priority over config_hash
12
13
14
|
# File 'lib/suzanne/env_reader.rb', line 12
def initialize(config_hash)
@env = config_hash.merge(ENV)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method) ⇒ Object
37
38
39
40
41
42
43
44
45
|
# File 'lib/suzanne/env_reader.rb', line 37
def method_missing(method, *)
key, punctuation = (method)
return fetch_key!(key) if punctuation == '!'
return !!send(key) if punctuation == '?'
return get_value(key) if key && !punctuation
rescue NoMethodError
super
end
|
Instance Method Details
#inspect ⇒ Object
20
21
22
|
# File 'lib/suzanne/env_reader.rb', line 20
def inspect
'Suzanne env'
end
|
#respond_to?(method) ⇒ Boolean
24
25
26
27
28
29
30
31
|
# File 'lib/suzanne/env_reader.rb', line 24
def respond_to?(method, *)
key, punctuation = (method)
return true if punctuation == '?'
return (key?(key) || super) if punctuation == '!'
true
end
|
#to_s ⇒ Object
16
17
18
|
# File 'lib/suzanne/env_reader.rb', line 16
def to_s
'Suzanne env'
end
|