<commit_before>module EventStore
  module Client
    module HTTP
      class EventData
        class Write < EventData
          attribute :id

          def assign_id
            raise IdentityError, "ID is already assigned (ID: #{id})" unless id.nil?
            self.id = uuid.get
          end

          def serialize
            json_formatted_data.to_json
          end

          def json_formatted_data
            json_data = {
              'eventId' => id,
              'eventType' => type
            }

            json_data['data'] = Casing::Camel.(data) if data
            json_data['metadata'] = Casing::Camel.(metadata) if metadata

            json_data
          end
        end
      end
    end
  end
end<commit_msg>Event data attribute names are not preserved as symbols when serializing them for writing<commit_after>module EventStore
  module Client
    module HTTP
      class EventData
        class Write < EventData
          attribute :id

          def assign_id
            raise IdentityError, "ID is already assigned (ID: #{id})" unless id.nil?
            self.id = uuid.get
          end

          def serialize
            json_formatted_data.to_json
          end

          def json_formatted_data
            json_data = {
              'eventId' => id,
              'eventType' => type
            }

            json_data['data'] = Casing::Camel.(data, convert_symbols: true) if data
            json_data['metadata'] = Casing::Camel.(metadata, convert_symbols: true) if metadata

            json_data
          end
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.06741573033707865, 'fraction_numerical': 0.0, 'mean_word_length': 1.5363924050632911, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3426429', 'n_tokens_mistral': 425, 'n_tokens_neox': 416, 'n_words': 124}