Module: Contracts

Includes:
Attrs, Builtin
Defined in:
lib/contracts/formatters.rb,
lib/contracts.rb,
lib/contracts/core.rb,
lib/contracts/attrs.rb,
lib/contracts/engine.rb,
lib/contracts/errors.rb,
lib/contracts/support.rb,
lib/contracts/version.rb,
lib/contracts/call_with.rb,
lib/contracts/decorators.rb,
lib/contracts/invariants.rb,
lib/contracts/validators.rb,
lib/contracts/engine/base.rb,
lib/contracts/engine/target.rb,
lib/contracts/method_handler.rb,
lib/contracts/method_reference.rb,
lib/contracts/builtin_contracts.rb,
lib/contracts/engine/eigenclass.rb

Overview

rdoc This module contains all the builtin contracts. If you want to use them, first:

import Contracts

And then use these or write your own!

A simple example:

Contract Num, Num => Num
def add(a, b)
  a + b
end

The contract is Contract Num, Num, Num. That says that the add function takes two numbers and returns a number.

Defined Under Namespace

Modules: Attrs, Builtin, CallWith, Core, Engine, Formatters, Invariants, MethodDecorators, Support, Validators Classes: ContractsNotIncluded, Decorator, MethodHandler, MethodReference, SingletonMethodReference

Constant Summary collapse

VERSION =
"0.17.2"

Constants included from Builtin

Builtin::ArrayOf, Builtin::SetOf

Class Method Summary collapse

Methods included from Attrs

#attr_accessor_with_contract, #attr_reader_with_contract, #attr_writer_with_contract

Class Method Details

.extended(base) ⇒ Object



23
24
25
# File 'lib/contracts.rb', line 23

def self.extended(base)
  base.send(:extend, Core)
end

.included(base) ⇒ Object



19
20
21
# File 'lib/contracts.rb', line 19

def self.included(base)
  base.send(:include, Core)
end