Sha256: 21d104f13440f5add42750d4b48c2fdc29b247ca212cd407aff6246a1250d5b4

Contents?: true

Size: 724 Bytes

Versions: 2

Compression:

Stored size: 724 Bytes

Contents

# frozen_string_literal: true

class BCDD::Result::Expectations
  module Contract
    require_relative 'contract/interface'
    require_relative 'contract/evaluator'
    require_relative 'contract/disabled'
    require_relative 'contract/for_types'
    require_relative 'contract/for_types_and_values'

    NONE = Contract::Evaluator.new(Contract::Disabled, Contract::Disabled).freeze

    ToEnsure = ->(spec) do
      return Contract::Disabled if spec.nil?

      spec.is_a?(Hash) ? Contract::ForTypesAndValues.new(spec) : Contract::ForTypes.new(Array(spec))
    end

    def self.new(success:, failure:)
      Contract::Evaluator.new(ToEnsure[success], ToEnsure[failure])
    end

    private_constant :ToEnsure
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bcdd-result-0.6.0 lib/bcdd/result/expectations/contract.rb
bcdd-result-0.5.0 lib/bcdd/result/expectations/contract.rb