Class: Yell::Repository
- Inherits:
-
Object
- Object
- Yell::Repository
- Extended by:
- MonitorMixin
- Includes:
- Singleton
- Defined in:
- lib/yell/repository.rb
Class Method Summary collapse
-
.[](name) ⇒ Yell::Logger
Get loggers from the repository.
-
.[]=(name, logger) ⇒ Yell::Logger
Set loggers in the repository.
-
.loggers ⇒ Hash
Get the list of all loggers in the repository.
Instance Method Summary collapse
-
#__fetch__(name) ⇒ Object
Fetch the logger by the given name.
-
#initialize ⇒ Repository
constructor
A new instance of Repository.
- #loggers ⇒ Object
Constructor Details
#initialize ⇒ Repository
Returns a new instance of Repository.
16 17 18 |
# File 'lib/yell/repository.rb', line 16 def initialize @loggers = {} end |
Class Method Details
.[](name) ⇒ Yell::Logger
Get loggers from the repository
37 38 39 |
# File 'lib/yell/repository.rb', line 37 def self.[]( name ) synchronize { instance.__fetch__(name) or raise Yell::LoggerNotFound.new(name) } end |
.[]=(name, logger) ⇒ Yell::Logger
Set loggers in the repository
26 27 28 |
# File 'lib/yell/repository.rb', line 26 def self.[]=( name, logger ) synchronize { instance.loggers[name] = logger } end |
.loggers ⇒ Hash
Get the list of all loggers in the repository
44 45 46 |
# File 'lib/yell/repository.rb', line 44 def self.loggers synchronize { instance.loggers } end |
Instance Method Details
#__fetch__(name) ⇒ Object
Fetch the logger by the given name.
If the logger could not be found and has a superclass, it will attempt to look there. This is important for the Yell::Loggable module.
60 61 62 63 64 65 66 67 68 |
# File 'lib/yell/repository.rb', line 60 def __fetch__( name ) logger = loggers[name] || loggers[name.to_s] if logger.nil? && name.respond_to?(:superclass) return __fetch__(name.superclass) end logger end |
#loggers ⇒ Object
49 50 51 |
# File 'lib/yell/repository.rb', line 49 def loggers @loggers end |