Module: CMDx::Utils::Format
Overview
Utility module for formatting data structures into log-friendly strings and converting messages to appropriate formats for logging
Instance Method Summary collapse
-
#to_log(message) ⇒ Hash, Object
Converts a message to a format suitable for logging.
-
#to_str(hash, &block) ⇒ String
Converts a hash to a formatted string using a custom formatter.
Instance Method Details
#to_log(message) ⇒ Hash, Object
Converts a message to a format suitable for logging
34 35 36 37 38 39 40 |
# File 'lib/cmdx/utils/format.rb', line 34 def to_log() if .respond_to?(:to_h) && .class.ancestors.any? { |a| a.to_s.start_with?("CMDx") } .to_h else end end |
#to_str(hash, &block) ⇒ String
Converts a hash to a formatted string using a custom formatter
59 60 61 62 |
# File 'lib/cmdx/utils/format.rb', line 59 def to_str(hash, &block) block ||= FORMATTER hash.map(&block).join(" ") end |