Module: Contracts
- Included in:
- Obj, ObjWithInvariants
- Defined in:
- lib/contracts-ruby2/lib/contracts/builtin_contracts.rb,
lib/contracts-ruby2/lib/contracts.rb,
lib/contracts-ruby3/lib/contracts.rb,
lib/contracts-ruby2/spec/support_spec.rb,
lib/contracts-ruby3/spec/support_spec.rb,
lib/contracts-ruby2/lib/contracts/core.rb,
lib/contracts-ruby3/lib/contracts/core.rb,
lib/contracts-ruby2/lib/contracts/attrs.rb,
lib/contracts-ruby3/lib/contracts/attrs.rb,
lib/contracts-ruby2/lib/contracts/engine.rb,
lib/contracts-ruby2/lib/contracts/errors.rb,
lib/contracts-ruby2/spec/invariants_spec.rb,
lib/contracts-ruby3/lib/contracts/engine.rb,
lib/contracts-ruby3/lib/contracts/errors.rb,
lib/contracts-ruby3/spec/invariants_spec.rb,
lib/contracts-ruby2/lib/contracts/support.rb,
lib/contracts-ruby2/lib/contracts/version.rb,
lib/contracts-ruby3/lib/contracts/support.rb,
lib/contracts-ruby3/lib/contracts/version.rb,
lib/contracts-ruby2/lib/contracts/call_with.rb,
lib/contracts-ruby3/lib/contracts/call_with.rb,
lib/contracts-ruby2/lib/contracts/decorators.rb,
lib/contracts-ruby2/lib/contracts/formatters.rb,
lib/contracts-ruby2/lib/contracts/invariants.rb,
lib/contracts-ruby2/lib/contracts/validators.rb,
lib/contracts-ruby3/lib/contracts/decorators.rb,
lib/contracts-ruby3/lib/contracts/formatters.rb,
lib/contracts-ruby3/lib/contracts/invariants.rb,
lib/contracts-ruby3/lib/contracts/validators.rb,
lib/contracts-ruby2/lib/contracts/engine/base.rb,
lib/contracts-ruby3/lib/contracts/engine/base.rb,
lib/contracts-ruby2/lib/contracts/engine/target.rb,
lib/contracts-ruby3/lib/contracts/engine/target.rb,
lib/contracts-ruby2/lib/contracts/method_handler.rb,
lib/contracts-ruby3/lib/contracts/method_handler.rb,
lib/contracts-ruby2/lib/contracts/method_reference.rb,
lib/contracts-ruby3/lib/contracts/method_reference.rb,
lib/contracts-ruby2/lib/contracts/engine/eigenclass.rb,
lib/contracts-ruby3/lib/contracts/builtin_contracts.rb,
lib/contracts-ruby3/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"
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-ruby2/lib/contracts.rb', line 20 def self.extended(base) base.send(:extend, Core) end |
.included(base) ⇒ Object
16 17 18 |
# File 'lib/contracts-ruby2/lib/contracts.rb', line 16 def self.included(base) base.send(:include, Core) end |