Sha256: 97e862f0d07708a1e66674cf8b7e7c38394c7bbe1b50c888c86f6d4f824c48d0

Contents?: true

Size: 527 Bytes

Versions: 1

Compression:

Stored size: 527 Bytes

Contents

# frozen_string_literal: true

module Intercept
  module Decorator
    class Replace
      attr_reader :replace_value

      def initialize(replace_value)
        @replace_value = parse_replace_value replace_value
      end

      def decorate(_)
        replace_value.call
      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

1 entries across 1 versions & 1 rubygems

Version Path
intercept-0.2.5 lib/intercept/decorator/replace.rb