lib/type_contracts/param.rb
def param(param_name, contract = NO_CONTRACT, &block)
        contract = TypeContracts::Param.new(param_name, contract, &block)

        @__type_contracts__last_annotation ||= {}
        @__type_contracts__last_annotation[:params] ||= []
        @__type_contracts__last_annotation[:params] << contract
      end
# Defines a contract for a single parameter on the next method that gets defined.
#
# @param param_name [Symbol]
#   the name of the parameter the contract is applied to
# @param contract
#   the contract for the parameter.  This could be a specific value (eg '1'),
#   a class (eg String), an array of possible values or matches (eg [String, Symbol]),
#   or a matcher that that has a no-arg constructor.  This can also be excluded and
#   a block provided instead; the block accepts the return value of the method and must
#   return a boolean value
Defines a contract for a single parameter on the next method that gets defined.
Defines a contract for a single parameter on the next method that gets defined .
def param(param_name, contract = NO_CONTRACT, &block)
        contract = TypeContracts::Param.new(param_name, contract, &block)
        @__type_contracts__last_annotation ||= {}
        @__type_contracts__last_annotation[:params] ||= []
        @__type_contracts__last_annotation[:params] << contract
      end
def param ( param_name , contract = NO_CONTRACT , & block ) contract = TypeContracts :: Param . new ( param_name , contract , & block ) @__type_contracts__last_annotation ||= { } @__type_contracts__last_annotation [ :params ] ||= [ ] @__type_contracts__last_annotation [ :params ] << contract end
Defines a contract for a single parameter on the next method that gets defined.
Defines a contract for a single parameter on the next method that gets defined .
param_name
the name of the parameter the contract is applied to
the name of the parameter the contract is applied to
contract
the contract for the parameter. This could be a specific value , a class , an array of possible values or matches , or a matcher that that has a no-arg constructor. This can also be excluded and a block provided instead; the block accepts the return value of the method and must return a boolean value
the contract for the parameter . This could be a specific value a class an array of possible values or matches or a matcher that that has a no - arg constructor . This can also be excluded and a block provided instead ; the block accepts the return value of the method and must return a boolean value
block