Class: Stannum::Constraints::Parameters::ExtraKeywords

Inherits:
Hashes::ExtraKeys show all
Defined in:
lib/stannum/constraints/parameters/extra_keywords.rb

Overview

Validates that the keywords passed to a method have no extra keys.

Examples:

keys       = %[fuel mass size]
constraint = Stannum::Constraints::Parameters::ExpectedKeywords.new(keys)

constraint.matches?({})                                #=> true
constraint.matches?({ fuel: 'Monopropellant' })        #=> true
constraint.matches?({ electric: true, fuel: 'Xenon' }) #=> false
constraint.matches?({ fuel: 'LF/O', mass: '1 ton', size: 'Medium' })
#=> true
constraint.matches?(
  { fuel: 'LF', mass: '2 tons', nuclear: true, size: 'Medium' }
)
#=> false

Constant Summary collapse

NEGATED_TYPE =

The :type of the error generated for a matching object.

'stannum.constraints.parameters.no_extra_keywords'
TYPE =

The :type of the error generated for a non-matching object.

'stannum.constraints.parameters.extra_keywords'

Instance Attribute Summary

Attributes inherited from Base

#options

Method Summary

Methods inherited from Hashes::ExtraKeys

#does_not_match?, #errors_for, #expected_keys, #initialize, #matches?

Methods inherited from Base

#==, #clone, #does_not_match?, #dup, #errors_for, #initialize, #match, #matches?, #message, #negated_errors_for, #negated_match, #negated_message, #negated_type, #type, #with_options

Constructor Details

This class inherits a constructor from Stannum::Constraints::Hashes::ExtraKeys