A library for defining and validating data structures.
Builder class for defining item constraints for a ParametersContract.
This class should not be invoked directly. Instead, pass a block to the constructor for ParametersContract.
#argument(name, type, index: nil, **options) => Stannum::Contracts::ParametersContract::Builder
#argument(name, index: nil, **options, &block) => Stannum::Contracts::ParametersContract::Builder
Adds an argument constraint to the contract.
If the index is specified, then the constraint will be added for the argument at the specified index. If the index is not given, then the constraint will be applied to the next unconstrained argument. For example, the first argument constraint will be added for the argument at index 0, the second constraint for the argument at index 1, and so on.
#argument(name, type, index: nil, **options) => Stannum::Contracts::ParametersContract::Builder
Generates an argument constraint based on the given type. If the type is a constraint, then the given constraint will be copied with the given options and added for the argument at the index. If the type is a Class or a Module, then a Stannum::Constraints::Type constraint will be created with the given type and options and added for the argument.
#argument(name, index: nil, **options, &block) => Stannum::Contracts::ParametersContract::Builder
Generates a new Stannum::Constraint using the block.
#arguments(name, type) => Stannum::Contracts::ParametersContract::Builder
Sets the variadic arguments constraint for the contract.
If the parameters includes variadic (or “splatted”) arguments, then each item in the variadic arguments array must match the given type or constraint. If the type is a constraint, then the given constraint will be copied with the given options. If the type is a Class or a Module, then a Stannum::Constraints::Type constraint will be created with the given type.
#block(present) => Stannum::Contracts::ParametersContract
Sets the block parameter constraint for the contract.
If the expected presence is true, a block must be given as part of the parameters. If the expected presence is false, a block must not be given. If the presence is a constraint, then the block must match the constraint.
#keyword(name, type, **options) => Stannum::Contracts::ParametersContract::Builder
#keyword(name, **options, &block) => Stannum::Contracts::ParametersContract::Builder
Adds a keyword constraint to the contract.
#keyword(name, type, **options) => Stannum::Contracts::ParametersContract::Builder
Generates a keyword constraint based on the given type. If the type is a constraint, then the given constraint will be copied with the given options and added for the given keyword. If the type is a Class or a Module, then a Stannum::Constraints::Type constraint will be created with the given type and options and added for the keyword.
#keyword(name, **options, &block) => Stannum::Contracts::ParametersContract::Builder
Generates a new Stannum::Constraint using the block.
#keywords(name, type) => Stannum::Contracts::ParametersContract::Builder
Sets the variadic keywords constraint for the contract.
If the parameters includes variadic (or “splatted”) keywords, then each value in the variadic keywords hash must match the given type or constraint. If the type is a constraint, then the given constraint will be copied with the given options. If the type is a Class or a Module, then a Stannum::Constraints::Type constraint will be created with the given type.
#property(property, constraint, **options) => Object
#property(**options) { |value| } => Object
Defines a property constraint on the contract.
#property(property, constraint, **options) => Object
Adds the given constraint to the contract for the property.
#property(**options) { |value| } => Object
Creates a new Stannum::Constraint object with the given block, and adds that constraint to the contract for the property.
Back to Documentation | Reference | Stannum | Stannum::Contracts | Stannum::Contracts::ParametersContract