Sha256: 801c1bc0c4e6165beaeb67095027350b8d231777c6d37dcba0a7309d616841fc

Contents?: true

Size: 398 Bytes

Versions: 3

Compression:

Stored size: 398 Bytes

Contents

module BloodContracts
  module Core
    class Contract
      class << self
        attr_accessor :input_type, :output_type
      end

      def self.call(*args)
        if (input_match = input_type.match(*args)).valid?
          result = yield(input_match)
          output_type.match(result, context: input_match.context)
        else
          input_match
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
blood_contracts-core-0.2.1 lib/blood_contracts/core/contract.rb
blood_contracts-core-0.2.0 lib/blood_contracts/core/contract.rb
blood_contracts-core-0.1.0 lib/blood_contracts/core/contract.rb