Sha256: b6193f811de48532b676e57fea6250ae3cbac66dc35d2d60611550ffe9c2d597
Contents?: true
Size: 739 Bytes
Versions: 11
Compression:
Stored size: 739 Bytes
Contents
# frozen_string_literal: true require "marameters" module Pipeable module Steps # Delegates to a non-callable object which automatically wraps the result if necessary. class To < Abstract def initialize(object, message, **) super(**) @object = object @message = message end def call result result.bind do |arguments| splat = Marameters.categorize object.method(message).parameters, arguments wrap object.public_send(message, *splat.positionals, **splat.keywords, &splat.block) end end private attr_reader :object, :message def wrap(result) = result.is_a?(Dry::Monads::Result) ? result : Success(result) end end end
Version data entries
11 entries across 11 versions & 1 rubygems