Module: Commons

Included in:
PPSCommons
Defined in:
lib/pps_commons/commons.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

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

instance version of self.deep_find()



45
46
47
# File 'lib/pps_commons/commons.rb', line 45

def deep_find(key, object=self, found=nil)
  Commons::ClassMethods.deep_find(key, object)
end

#logger(file = nil) ⇒ Object

TODO: accept a file path instead of somewhere in the gems



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/pps_commons/commons.rb', line 27

def logger(file = nil)
  if @logger.nil?
    log = ::File.expand_path(file)
    unless ::File.exist?(log)
      log_dir = File.dirname(log)
      unless ::Dir.exist?(log_dir)
        ::Dir.mkdir_p(log_dir)
      end
      ::File.new(log, 'a+')
    end

    Logger.new(log)
  else
    @logger
  end
end