class TaskArgumentFilterer
TaskArgumentFilterer
will recursively walk any arguemnts to a task and filter any hashes with a filtered key. By default only :password is filtered, but you can add more with Volt.config
.filter_keys
Public Class Methods
filter(args)
click to toggle source
# File lib/volt/utils/logging/task_argument_filterer.rb, line 5 def self.filter(args) new(args).run end
new(args)
click to toggle source
# File lib/volt/utils/logging/task_argument_filterer.rb, line 9 def initialize(args) # # Cache the filter args @@filter_args ||= begin # Load, with default, convert to symbols arg_names = (Volt.config.filter_keys || [:password]).map(&:to_sym) end @args = args end
Public Instance Methods
run()
click to toggle source
# File lib/volt/utils/logging/task_argument_filterer.rb, line 19 def run filter_args(@args) end
Private Instance Methods
filter_args(args)
click to toggle source
# File lib/volt/utils/logging/task_argument_filterer.rb, line 25 def filter_args(args) if args.is_a?(Array) args.map { |v| filter_args(v) } elsif args.is_a?(Hash) args.map do |k, v| if @@filter_args.include?(k.to_sym) # filter [k, '[FILTERED]'] else # retunr unfiltered [k, filter_args(v)] end end.to_h # <= convert back to hash else return args end end