From 0b966714b6984d9cd9b68bb04a5c49671fb90c17 Mon Sep 17 00:00:00 2001 From: Didactic Drunk <1479616+didactic-drunk@users.noreply.github.com> Date: Wed, 16 Jun 2021 15:17:14 -0700 Subject: [PATCH] Stateful: Keep state with #dup --- src/crypto-secret/stateful.cr | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/crypto-secret/stateful.cr b/src/crypto-secret/stateful.cr index c552645..c8aeeb4 100644 --- a/src/crypto-secret/stateful.cr +++ b/src/crypto-secret/stateful.cr @@ -105,6 +105,12 @@ module Crypto::Secret @state = State::Wiped end + def dup + super.tap do |obj| + obj.set_state @state + end + end + protected abstract def readwrite_impl : Nil protected abstract def readonly_impl : Nil protected abstract def noaccess_impl : Nil