Sha256: ff0386eeeead8815125e77309f0326e92acb3e3a41c644fd719f075269f0e71e

Contents?: true

Size: 949 Bytes

Versions: 1

Compression:

Stored size: 949 Bytes

Contents

# frozen_string_literal: true

class BCDD::Result
  module Expectations::Mixin
    module Factory
      def self.module!
        ::Module.new do
          def self.included(base); base.const_set(:ResultExpectationsMixin, self); end
          def self.extended(base); base.const_set(:ResultExpectationsMixin, self); end
        end
      end
    end

    METHODS = <<~RUBY
      def Success(...)
        _Result.Success(...)
      end

      def Failure(...)
        _Result.Failure(...)
      end

      private

      def _Result
        @_Result ||= Result.with(subject: self)
      end
    RUBY

    module Addons
      module Continuable
        private def Continue(value)
          Success.new(type: :continued, value: value, subject: self)
        end
      end

      OPTIONS = { continue: Continuable }.freeze

      def self.options(config_flags)
        Config::Options.addon(map: config_flags, from: OPTIONS)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bcdd-result-0.8.0 lib/bcdd/result/expectations/mixin.rb