class Stannum::Contract::Builder
Builder
class for defining item constraints for a Contract
.
This class should not be invoked directly. Instead, pass a block to the constructor for Contract
.
@api private
Public Instance Methods
property(property, constraint = nil, **options, &block)
click to toggle source
Defines a property constraint on the contract.
@overload property(property, constraint, **options)
Adds the given constraint to the contract for the property. @param property [String, Symbol, Array<String, Symbol>] The property to constrain. @param constraint [Stannum::Constraint::Base] The constraint to add. @param options [Hash<Symbol, Object>] Options for the constraint.
@overload property(**options) { |value| }
Creates a new Stannum::Constraint object with the given block, and adds that constraint to the contract for the property.
# File lib/stannum/contract.rb, line 120 def property(property, constraint = nil, **options, &block) self.constraint( constraint, property: property, **options, &block ) end