kit-contract edge

InstantiableContract class
Kit::Contract::BuiltInContracts::InstantiableContract
View Source

Helper class to memoize Contract values.


Link to this section Summary ⚠️ Private APIs are currently hidden.


Link to this section Class methods 2

Convenience use of the [] operator as an implicit .new.

Examples

# The two following are identical:
Eq[2]
Eq.new(args: [2])

Convenience Class method to generate a new Named contract


Link to this section Instance methods 8

Run contracts

When enabled, outputs the Contract arguments when called.

Meta accessor

Link to this method

#initialize(state: nil, args: nil, bypass_setup: false)

View Source RUBYConstructor

The ctor allows for creation (args) && duplication (state)

All the object state is held in the @state instance variable to simplify object cloning.

Assign meta information on the Contract.

⚠️ Warning: It it merged into the existing value.

Add a meta name to the Contract. This is helpfull for generating Error messages & debugging.

⚠️⚠️ Danger: when called, the Contract is cloned to avoid namig collisions. This is a tradeoffs between obvious side-effects & less obvious ones.

Link to this method

#safe_nested_call(list:, args:, contract:)

View Source

Handle circular reference when the contract can self-reference. If a circular reference is detected, skip the contract and let the top level one sort it out.

Handles initialization logic for InstantiableContracts


Link to this section Instance attributes 1

Purely for spec purpose. This allows to check that the safe mechanism actually does something.