class Aws::Log::ParamFormatter
@api private
Constants
- MAX_STRING_SIZE
String longer than the max string size are truncated
Public Class Methods
new(options = {})
click to toggle source
# File lib/aws-sdk-core/log/param_formatter.rb, line 11 def initialize(options = {}) @max_string_size = options[:max_string_size] || MAX_STRING_SIZE end
Public Instance Methods
summarize(value)
click to toggle source
# File lib/aws-sdk-core/log/param_formatter.rb, line 15 def summarize(value) Hash === value ? summarize_hash(value) : summarize_value(value) end
Private Instance Methods
summarize_array(array)
click to toggle source
# File lib/aws-sdk-core/log/param_formatter.rb, line 62 def summarize_array(array) "[" + array.map{|v| summarize_value(v) }.join(",") + "]" end
summarize_file(path)
click to toggle source
# File lib/aws-sdk-core/log/param_formatter.rb, line 58 def summarize_file(path) "#<File:#{path} (#{File.size(path)} bytes)>" end
summarize_hash(hash)
click to toggle source
# File lib/aws-sdk-core/log/param_formatter.rb, line 21 def summarize_hash(hash) hash.keys.first.is_a?(String) ? summarize_string_hash(hash) : summarize_symbol_hash(hash) end
summarize_string(str)
click to toggle source
# File lib/aws-sdk-core/log/param_formatter.rb, line 39 def summarize_string(str) if str.size > @max_string_size "#<String #{str[0...@max_string_size].inspect} ... (#{str.size} bytes)>" else str.inspect end end
summarize_string_hash(hash)
click to toggle source
# File lib/aws-sdk-core/log/param_formatter.rb, line 33 def summarize_string_hash(hash) hash.map do |key,v| "#{key.inspect}=>#{summarize_value(v)}" end.join(",") end
summarize_symbol_hash(hash)
click to toggle source
# File lib/aws-sdk-core/log/param_formatter.rb, line 27 def summarize_symbol_hash(hash) hash.map do |key,v| "#{key}:#{summarize_value(v)}" end.join(",") end
summarize_value(value)
click to toggle source
# File lib/aws-sdk-core/log/param_formatter.rb, line 47 def summarize_value(value) case value when String then summarize_string(value) when Hash then '{' + summarize_hash(value) + '}' when Array then summarize_array(value) when File then summarize_file(value.path) when Pathname then summarize_file(value) else value.inspect end end