Sha256: f0ffa8b52aa10a4e096f7b076cab6806ca9e413d4d4073a599e2947db9e2be6b
Contents?: true
Size: 762 Bytes
Versions: 9
Compression:
Stored size: 762 Bytes
Contents
# frozen_string_literal: true module ConvenientService module Service module Plugins module RaisesOnDoubleResult class Middleware < Core::MethodChainMiddleware def next(...) refute_has_result! || mark_as_has_result! chain.next(...) end private ## # NOTE: `refute` is `!assert`. # https://docs.seattlerb.org/minitest # def refute_has_result! return unless entity.internals.cache.exist?(:has_result) raise Errors::DoubleResult.new(service: entity) end def mark_as_has_result! entity.internals.cache.write(:has_result, true) end end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems