Sha256: b6bad7187d735f1efaeb0e853a5d7b33b8882dff2ea1a91dd1a345c94bb49cfc
Contents?: true
Size: 824 Bytes
Versions: 3
Compression:
Stored size: 824 Bytes
Contents
# frozen_string_literal: true # # Copyright (c) 2020-present, Blue Marble Payroll, LLC # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # module Realize class Format # This transformer takes in a value and replaces all occurrences of the given # original pattern with the replacement pattern. class StringReplace acts_as_hashable attr_reader :original, :replacement def initialize(original:, replacement:) raise ArgumentError, 'original is required' if original.to_s.empty? @original = original @replacement = replacement.to_s freeze end def transform(_resolver, value, _time, _record) value.to_s.gsub(original, replacement) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
realize-1.6.0 | lib/realize/format/string_replace.rb |
realize-1.5.0 | lib/realize/format/string_replace.rb |
realize-1.4.0 | lib/realize/format/string_replace.rb |