class Contracts::Builtin::KeywordArgs
Use this for specifying contracts for keyword arguments Example: KeywordArgs[ e: Range, f: Optional[Num] ]
Attributes
Public Class Methods
Source
# File lib/contracts/builtin_contracts.rb, line 444 def initialize(options) super() @options = options end
Calls superclass method
Public Instance Methods
Source
# File lib/contracts/builtin_contracts.rb, line 458 def to_s "KeywordArgs[#{options}]" end
Source
# File lib/contracts/builtin_contracts.rb, line 449 def valid?(hash) return false unless hash.is_a?(Hash) return false unless hash.keys - options.keys == [] options.all? do |key, contract| Optional._valid?(hash, key, contract) end end