module Leeroy::Helpers::Env
Attributes
env[R]
Public Instance Methods
checkEnv(param, check = lambda { |x| ! x.nil? }, errmsg = "You must provide
click to toggle source
# File lib/leeroy/helpers/env.rb, line 11 def checkEnv(param, check = lambda { |x| ! x.nil? }, errmsg = "You must provide #{param} in the environment.", env = self.env) begin logger.debug "checking for '#{param}' in environment" # get param from env candidate = env.fetch(param, nil) logger.debug "candidate: #{candidate}" # check it against the check check_passed = check.call(candidate) logger.debug "check_passed: #{check_passed}" if check_passed candidate else raise errmsg end rescue NoMethodError => e logger.error "unable to read environment! env: #{env.inspect}" raise e rescue StandardError => e raise e end end