Module: Figaro::ENV

Extended by:
ENV
Included in:
ENV
Defined in:
lib/figaro/env.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method) ⇒ Object (private)



17
18
19
20
21
22
23
24
25
26
# File 'lib/figaro/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

Instance Method Details

#respond_to?(method) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
8
9
10
11
12
13
# File 'lib/figaro/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