Sha256: 7b3ce3fd3d7577db0b3b3eb683e52f87ae692581f8bfc3b9c8c213b6ffbe5b87

Contents?: true

Size: 590 Bytes

Versions: 2

Compression:

Stored size: 590 Bytes

Contents

# frozen_string_literal: true

module Intercept
  module Strategy
    class Replace
      attr_reader :replace_value

      def initialize(replace_value)
        @replace_value = replace_value
      end

      def process(value)
        if value.nil? || value.empty?
          value
        else
          replace_value.call
        end
      end

      private

      def parse_replace_value(replace_value)
        if replace_value.respond_to?(:call)
          replace_value
        else
          raise '@param replace_value must respond to #call'
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
intercept-0.2.2 lib/intercept/strategy/replace.rb
intercept-0.2.1 lib/intercept/strategy/replace.rb