Module: Contracts
- Includes:
- Builtin
- Defined in:
- lib/contracts/builtin_contracts.rb,
lib/contracts.rb,
lib/contracts/core.rb,
lib/contracts/engine.rb,
lib/contracts/errors.rb,
lib/contracts/support.rb,
lib/contracts/version.rb,
lib/contracts/decorators.rb,
lib/contracts/formatters.rb,
lib/contracts/invariants.rb,
lib/contracts/engine/base.rb,
lib/contracts/engine/target.rb,
lib/contracts/args_validator.rb,
lib/contracts/method_handler.rb,
lib/contracts/error_formatter.rb,
lib/contracts/method_reference.rb,
lib/contracts/engine/eigenclass.rb,
lib/contracts/contract/call_with.rb,
lib/contracts/contract/validators.rb,
lib/contracts/contract/failure_callback.rb
Overview
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: Builtin, CallWith, Core, Engine, FailureCallback, Formatters, Invariants, MethodDecorators, Support, Validators Classes: ArgsValidator, ContractsNotIncluded, Decorator, DefaultErrorFormatter, ErrorFormatters, KeywordArgsErrorFormatter, MethodHandler, MethodReference, SingletonMethodReference
Constant Summary collapse
- VERSION =
"0.15.0".freeze
Constants included from Builtin
Builtin::ArrayOf, Builtin::SetOf
Class Method Summary collapse
Class Method Details
.extended(base) ⇒ Object
26 27 28 |
# File 'lib/contracts.rb', line 26 def self.extended(base) base.send(:extend, Core) end |
.included(base) ⇒ Object
22 23 24 |
# File 'lib/contracts.rb', line 22 def self.included(base) base.send(:include, Core) end |