Module: Contracts

Includes:
Attrs, Builtin
Defined in:
lib/contracts/builtin_contracts.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/formatters.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/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

VERSION =
"0.16.0"

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



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

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

.included(base) ⇒ Object



16
17
18
# File 'lib/contracts.rb', line 16

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