Class: Figaro::Env

Inherits:
Hash
  • Object
show all
Defined in:
lib/figaro/env.rb

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method) ⇒ Object



7
8
9
10
# File 'lib/figaro/env.rb', line 7

def method_missing(method, *)
  pair = ENV.detect { |k, _| k.upcase == method.to_s.upcase }
  pair ? pair[1] : super
end

Class Method Details

.from(hash) ⇒ Object



3
4
5
# File 'lib/figaro/env.rb', line 3

def self.from(hash)
  new.replace(hash)
end

Instance Method Details

#respond_to?(method) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/figaro/env.rb', line 12

def respond_to?(method, *)
  ENV.keys.any? { |k| k.upcase == method.to_s.upcase } || super
end