Class: Stannum::Contract::Builder Private

Inherits:
Stannum::Contracts::Base::Builder
  • Object
show all
Defined in:
lib/stannum/contract.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

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.

Instance Method Summary collapse

Instance Method Details

#property(property, constraint, **options) ⇒ Object #property(**options) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Defines a property constraint on the contract.

Overloads:

  • #property(property, constraint, **options) ⇒ Object

    Adds the given constraint to the contract for the property.

    Parameters:

    • property (String, Symbol, Array<String, Symbol>)

      The property to constrain.

    • constraint (Stannum::Constraint::Base)

      The constraint to add.

    • options (Hash<Symbol, Object>)

      Options for the constraint.

  • #property(**options) ⇒ Object

    Creates a new Stannum::Constraint object with the given block, and adds that constraint to the contract for the property.



120
121
122
123
124
125
126
127
# File 'lib/stannum/contract.rb', line 120

def property(property, constraint = nil, **options, &block)
  self.constraint(
    constraint,
    property: property,
    **options,
    &block
  )
end