Class: CLIUtils::LoggerDelegator
- Inherits:
-
Object
- Object
- CLIUtils::LoggerDelegator
- Defined in:
- lib/cliutils/logger-delegator.rb
Overview
LoggerDelegator Class
Manages any configuration values and the flat YAML file
into which they get stored.
======================================================
Instance Attribute Summary (collapse)
-
- (Object) devices
readonly
Attributes ====================================================.
Class Method Summary (collapse)
-
+ (Object) delegate
—————————————————- delegate_all method.
Instance Method Summary (collapse)
-
- (Object) attach(target)
—————————————————- attach method.
-
- (Object) detach(target)
—————————————————- detach method.
-
- (LoggerDelegator) initialize(*targets)
constructor
Methods ==================================================== —————————————————- initialize method.
Constructor Details
- (LoggerDelegator) initialize(*targets)
Methods
====================================================
----------------------------------------------------
initialize method
Initializer
@param *targets The endpoints to delegate to
@return void
----------------------------------------------------
24 25 26 27 |
# File 'lib/cliutils/logger-delegator.rb', line 24 def initialize(*targets) @targets = targets LoggerDelegator.delegate end |
Instance Attribute Details
- (Object) devices (readonly)
Attributes
====================================================
12 13 14 |
# File 'lib/cliutils/logger-delegator.rb', line 12 def devices @devices end |
Class Method Details
+ (Object) delegate
delegate_all method
Creates delegator methods for all of the methods
on IO.
@return void
----------------------------------------------------
47 48 49 50 51 52 53 |
# File 'lib/cliutils/logger-delegator.rb', line 47 def self.delegate %w(log debug info warn error section success).each do |m| define_method(m) do |*args| @targets.map { |t| t.send(m, *args) } end end end |
Instance Method Details
- (Object) attach(target)
attach method
Attaches a new target to delegate to.
@return void
----------------------------------------------------
35 36 37 38 |
# File 'lib/cliutils/logger-delegator.rb', line 35 def attach(target) @targets << target LoggerDelegator.delegate end |
- (Object) detach(target)
detach method
Detaches a delegation target.
@return void
----------------------------------------------------
61 62 63 64 |
# File 'lib/cliutils/logger-delegator.rb', line 61 def detach(target) @targets.delete(target) LoggerDelegator.delegate end |