class Fried::Typings::HashOf

Checks if all key => value elements of the hashmap match the types pair

Attributes

key_type[R]
value_type[R]

Public Class Methods

new(key_type, value_type) click to toggle source
# File lib/fried/typings/hash_of.rb, line 21
def initialize(key_type, value_type)
  @key_type = key_type
  @value_type = value_type
end

Public Instance Methods

valid?(hsh) click to toggle source

@param hsh [Hash]

# File lib/fried/typings/hash_of.rb, line 27
def valid?(hsh)
  return false unless Is[Hash].valid?(hsh)

  enumerator = hsh.each

  EnumeratorOf[TupleOf[key_type, value_type]].valid?(enumerator)
end