Module: WGU::PPSCommons::InstanceMethods

Defined in:
lib/pps_commons.rb

Overview

Common instance methods

Instance Method Summary collapse

Instance Method Details

#deep_find(key, object = self, found = nil) ⇒ Object

instance version of self.deep_find()



53
54
55
# File 'lib/pps_commons.rb', line 53

def deep_find(key, object=self, found=nil)
  WGU::PPSCommons.deep_find(key, object)
end

#logger(file = ENV['PPS_COMMONS_DEFAULT_LOG_LOCATION'] || STDOUT) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/pps_commons.rb', line 32

def logger(file = ENV['PPS_COMMONS_DEFAULT_LOG_LOCATION'] || STDOUT)
  if @logger.nil?
    log = file.eql?(STDOUT) ? file : nil

    unless file.eql? STDOUT
      log = ::File.expand_path(file)
      unless ::File.exist?(log)
        log_dir = File.dirname(log)
        unless ::Dir.exist?(log_dir)
          ::FileUtils.mkdir_p(log_dir)
        end
        ::File.new(log, 'a+')
      end
    end

    Logger.new(log)
  else
    @logger
  end
end