Sha256: 35dcd969b1303212a13712d2aa03243052dd2e1cc18a1bc893431061f8121b6c
Contents?: true
Size: 798 Bytes
Versions: 5
Compression:
Stored size: 798 Bytes
Contents
module Timber module Util # @private # # The purpose of this class is to efficiently build a hash that does not # include nil values. It's proactive instead of reactive, avoiding the # need to traverse and reduce a new hash dropping blanks. class NonNilHashBuilder class << self def build(&block) builder = new yield builder builder.target end end attr_reader :target def initialize @target = {} end def add(k, v, options = {}) if !v.nil? if options[:json_encode] v = v.to_json end if options[:limit] v = v.byteslice(0, options[:limit]) end @target[k] = v end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems