From 25a8be34971039e7315345a4bc5a2b280559db18 Mon Sep 17 00:00:00 2001 From: Vladimir Dementyev Date: Fri, 22 Mar 2024 21:30:42 -0700 Subject: [PATCH] fix: deserialize Hashes as HWIA For backward-compatibility --- lib/anycable/rails/channel_state.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/anycable/rails/channel_state.rb b/lib/anycable/rails/channel_state.rb index d8e8922..921cdb7 100644 --- a/lib/anycable/rails/channel_state.rb +++ b/lib/anycable/rails/channel_state.rb @@ -12,9 +12,10 @@ def #{name} return @#{name} if instance_variable_defined?(:@#{name}) return unless anycabled? - val = __istate__["#{name}"] + raw_val = __istate__["#{name}"] + val = raw_val.present? ? AnyCable::Serializer.deserialize(JSON.parse(raw_val)) : nil - @#{name} = val.present? ? AnyCable::Serializer.deserialize(JSON.parse(val)) : nil + @#{name} = val.try(:with_indifferent_access) || val end def #{name}=(val)