Sha256: 9aade411ea35fd5b515dbae192221d890d717780a8e61677d8f329bf1bbc3404

Contents?: true

Size: 483 Bytes

Versions: 1

Compression:

Stored size: 483 Bytes

Contents

module Intercept
  module Decorator
    class AddSuffix
      attr_reader :suffix

      def initialize(suffix)
        @suffix = parse_suffix suffix
      end

      def decorate(value)
        return value unless String === value

        "#{value}#{suffix.call}"
      end

      private

      def parse_suffix(suffix)
        if suffix.respond_to?(:call)
          suffix
        else
          raise '@param suffix 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/add_suffix.rb