Sha256: 35c16502d4261aa27e57bd05d1dc110b51c11cd03ce17e12f9a16f43dee61b61

Contents?: true

Size: 901 Bytes

Versions: 2

Compression:

Stored size: 901 Bytes

Contents

# frozen_string_literal: true

require 'dry/effects/initializer'
require 'dry/effects/provider/class_interface'

module Dry
  module Effects
    # Base class for effect providers
    #
    # @api private
    class Provider
      extend Initializer
      extend ClassInterface

      # yield the block with the handler installed
      #
      # @api private
      def call(_stack)
        yield
      end

      # Effect-specific representation of the provider
      #
      # @return [String]
      # @api public
      def represent
        type.to_s
      end

      # Effect type
      #
      # @return [Symbol]
      # @api public
      def type
        self.class.type
      end

      # Whether the effect can be handled?
      #
      # @param [Effect] effect
      # @return [Boolean]
      # @api public
      def provide?(effect)
        type.equal?(effect.type)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dry-effects-0.1.1 lib/dry/effects/provider.rb
dry-effects-0.1.0 lib/dry/effects/provider.rb