Module: Solid::Result::Contract

Defined in:
lib/solid/result/contract.rb,
lib/solid/result/contract/type_checker.rb

Defined Under Namespace

Modules: Disabled, Interface Classes: Error, Evaluator, ForTypes, ForTypesAndValues

Constant Summary collapse

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

Class Method Summary collapse

Class Method Details

.evaluate(data, contract) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/solid/result/contract.rb', line 14

def self.evaluate(data, contract)
  contract ||= NONE

  contract.type_and_value!(data)

  TypeChecker.new(data.type, expectations: contract)
end

.new(success:, failure:, config:) ⇒ Object



28
29
30
# File 'lib/solid/result/contract.rb', line 28

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