module Jangle module StringReplacer # An array of [to_replace, replacement] pairs, used to # replace strings within the request body. attr_accessor :replacements # Always returns a string, converting nil data into '' def do_replacements(data) unless data.nil? @replacements.each do |to_replace, replacement| data = data.gsub(to_replace, replacement) end else data = '' end data end end end