Module: Paquito::TypedStruct::ClassMethods

Extended by:
T::Sig
Defined in:
lib/paquito/typed_struct.rb

Instance Method Summary collapse

Instance Method Details

#from_pack(packed) ⇒ Object



39
40
41
42
43
44
45
46
# File 'lib/paquito/typed_struct.rb', line 39

def from_pack(packed)
  digest, *values = packed
  if pack_digest != digest
    raise(VersionMismatchError, "#{self} digests do not match")
  end

  new(**props.keys.zip(values).to_h)
end

#pack_digestObject



49
50
51
# File 'lib/paquito/typed_struct.rb', line 49

def pack_digest
  @pack_digest ||= Paquito::Struct.digest(props.keys)
end