Sha256: 785279dbf7a1957506d5715408409f6f263539820e7b06a6618899c65db39428

Contents?: true

Size: 557 Bytes

Versions: 1

Compression:

Stored size: 557 Bytes

Contents

# frozen_string_literal: true

module BCDD::Contract
  module Core::Checker
    def [](value)
      checking.new(strategy, value)
    end

    def ===(value)
      self[value].valid?
    end

    def to_proc
      ->(value) { self[value] }
    end

    def invariant(value)
      self[value].raise_validation_errors!

      output = yield(value)

      self[value].raise_validation_errors!

      output
    end

    protected

    def checking
      const_get(:CHECKING, false)
    end

    def strategy
      const_get(:STRATEGY, false)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bcdd-contract-0.1.0 lib/bcdd/contract/core/checker.rb