class Dry::Effects::Provider

Base class for effect providers

@api private

Public Instance Methods

call() { || ... } click to toggle source

yield the block with the handler installed

@api private

# File lib/dry/effects/provider.rb, line 18
def call
  yield
end
inspect() click to toggle source

@return [String] @api public

# File lib/dry/effects/provider.rb, line 49
def inspect
  "#<#{self.class.name} #{represent}>"
end
provide?(effect) click to toggle source

Whether the effect can be handled?

@param [Effect] effect @return [Boolean] @api public

# File lib/dry/effects/provider.rb, line 43
def provide?(effect)
  type.equal?(effect.type)
end
represent() click to toggle source

Effect-specific representation of the provider

@return [String] @api public

# File lib/dry/effects/provider.rb, line 26
def represent
  type.to_s
end
type() click to toggle source

Effect type

@return [Symbol] @api public

# File lib/dry/effects/provider.rb, line 34
def type
  self.class.type
end

Private Instance Methods

value_with_options_from_args(args) click to toggle source
# File lib/dry/effects/provider.rb, line 55
def value_with_options_from_args(args)
  case args.size
  when 2
    args
  when 1
    if args[0].is_a?(::Hash)
      [Undefined, args[0]]
    else
      [args[0], EMPTY_HASH]
    end
  when 0
    [Undefined, EMPTY_HASH]
  end
end