Sha256: 10661421b250cb2b8ea2cd1f4e3766fb8c5e761c198a5a93d6931068441c0ec7
Contents?: true
Size: 1.77 KB
Versions: 2
Compression:
Stored size: 1.77 KB
Contents
module Nucleon class Core < Config #----------------------------------------------------------------------------- # Properties @@logger = Util::Logger.new('core') @@ui = Util::Console.new('core') @@ui_lock = Mutex.new #----------------------------------------------------------------------------- # Constructor / Destructor def initialize(data = {}, defaults = {}, force = true) super(data, defaults, force) class_label = self.class.to_s.downcase.gsub(/^nucleon::/, '') self.logger = delete(:logger, class_label) self.ui = Config.new(export).defaults({ :resource => class_label }) logger.debug('Initialized instance logger and interface') end #----------------------------------------------------------------------------- # Accessor / Modifiers attr_reader :logger, :ui #--- def self.logger return @@logger end def logger=logger Util::Logger.loggers.delete(self.logger.resource) if self.logger if logger.is_a?(Util::Logger) @logger = logger else @logger = Util::Logger.new(logger) end end #--- def self.ui return @@ui end def ui=ui if ui.is_a?(Util::Console) @ui = ui else @ui = Util::Console.new(ui) end end #----------------------------------------------------------------------------- # General utilities def self.ui_group(resource) @@ui_lock.synchronize do begin ui_resource = ui.resource ui.resource = resource yield(ui) ensure ui.resource = ui_resource end end end #--- def ui_group(resource) ui_resource = ui.resource ui.resource = resource yield(ui) ensure ui.resource = ui_resource end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
nucleon-0.1.6 | lib/core/core.rb |
nucleon-0.1.5 | lib/core/core.rb |