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.
14 15 16 |
# File 'lib/yell/repository.rb', line 14 def initialize @loggers = {} end |
Class Method Details
.[](name) ⇒ Yell::Logger
Get loggers from the repository
35 36 37 |
# File 'lib/yell/repository.rb', line 35 def self.[]( name ) synchronize { instance.__fetch__(name) or raise Yell::LoggerNotFound.new(name) } end |
.[]=(name, logger) ⇒ Yell::Logger
Set loggers in the repository
24 25 26 |
# File 'lib/yell/repository.rb', line 24 def self.[]=( name, logger ) synchronize { instance.loggers[name] = logger } end |
.loggers ⇒ Hash
Get the list of all loggers in the repository
42 43 44 |
# File 'lib/yell/repository.rb', line 42 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.
58 59 60 61 62 63 64 65 66 |
# File 'lib/yell/repository.rb', line 58 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
47 48 49 |
# File 'lib/yell/repository.rb', line 47 def loggers @loggers end |