Sha256: 86bf16e1e86a91d1a679439eb56b9d0f1b477f1d2bf70923a18387a91cc3a9e0
Contents?: true
Size: 1.93 KB
Versions: 3
Compression:
Stored size: 1.93 KB
Contents
module CLIUtils # ====================================================== # LoggerDelegator Class # # Manages any configuration values and the flat YAML file # into which they get stored. # ====================================================== class LoggerDelegator # ==================================================== # Attributes # ==================================================== attr_reader :devices # ==================================================== # Methods # ==================================================== # ---------------------------------------------------- # initialize method # # Initializer # @param *targets The endpoints to delegate to # @return void # ---------------------------------------------------- def initialize(*targets) @targets = targets LoggerDelegator.delegate end # ---------------------------------------------------- # attach method # # Attaches a new target to delegate to. # @return void # ---------------------------------------------------- def attach(target) @targets << target LoggerDelegator.delegate end # ---------------------------------------------------- # delegate_all method # # Creates delegator methods for all of the methods # on IO. # @return void # ---------------------------------------------------- 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 # ---------------------------------------------------- # detach method # # Detaches a delegation target. # @return void # ---------------------------------------------------- def detach(target) @targets.delete(target) LoggerDelegator.delegate end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
cliutils-1.0.2 | lib/cliutils/logger-delegator.rb |
cliutils-1.0.1 | lib/cliutils/logger-delegator.rb |
cliutils-1.0.0 | lib/cliutils/logger-delegator.rb |