module S3Config::ENV
Public Instance Methods
respond_to?(method, *)
click to toggle source
Calls superclass method
# File lib/s3_config/env.rb, line 5 def respond_to?(method, *) key, punctuation = extract_key_from_method(method) case punctuation when "!" then has_key?(key) || super when "?", nil then true else super end end
Private Instance Methods
extract_key_from_method(method)
click to toggle source
# File lib/s3_config/env.rb, line 28 def extract_key_from_method(method) method.to_s.downcase.match(/^(.+?)([!?=])?$/).captures end
get_value(key)
click to toggle source
# File lib/s3_config/env.rb, line 40 def get_value(key) _, value = ::ENV.detect { |k, _| k.downcase == key } value end
has_key?(key)
click to toggle source
# File lib/s3_config/env.rb, line 32 def has_key?(key) ::ENV.any? { |k, _| k.downcase == key } end
method_missing(method, *)
click to toggle source
Calls superclass method
# File lib/s3_config/env.rb, line 17 def method_missing(method, *) key, punctuation = extract_key_from_method(method) case punctuation when "!" then send(key) || missing_key!(key) when "?" then !!send(key) when nil then get_value(key) else super end end
missing_key!(key)
click to toggle source
# File lib/s3_config/env.rb, line 36 def missing_key!(key) raise MissingKey.new(key) end