Class: ChefLicensing::EnvFetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/chef-licensing/config_fetcher/env_fetcher.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env = ENV) ⇒ EnvFetcher

Returns a new instance of EnvFetcher.



4
5
6
# File 'lib/chef-licensing/config_fetcher/env_fetcher.rb', line 4

def initialize(env = ENV)
  @env = env
end

Class Method Details

.fetch_value(env_name, env_type = :string) ⇒ Object



17
18
19
# File 'lib/chef-licensing/config_fetcher/env_fetcher.rb', line 17

def self.fetch_value(env_name, env_type = :string)
  new.fetch_value(env_name, env_type)
end

Instance Method Details

#fetch_value(env_name, env_type = :string) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/chef-licensing/config_fetcher/env_fetcher.rb', line 8

def fetch_value(env_name, env_type = :string)
  case env_type
  when :boolean
    @env.key?(env_name)
  when :string
    @env.fetch(env_name, nil)
  end
end