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)