<commit_before># frozen_string_literal: true

module Websocket
  extend ActiveSupport::Concern

  included do
    after_create :broadcast_create
    after_update :broadcast_update

    def broadcast_event(type)
      event_class = self.class.to_s
      channel = event_class.pluralize.underscore
      object_data = attributes.delete_if { |k, _| AppConfig['sensitive_fields'].include? "#{channel}.#{k}" }
      extended = respond_to?(:extended_websocket) ? extended_websocket : nil
      object_data.deep_merge! extended
      ApiChannel.broadcast_to channel, event_type: type, event_class: event_class, object: object_data
    end

    def broadcast_create
      broadcast_event 'create'
    end

    def broadcast_update
      broadcast_event 'update'
    end
  end
end<commit_msg>Avoid merge errors<commit_after># frozen_string_literal: true

module Websocket
  extend ActiveSupport::Concern

  included do
    after_create :broadcast_create
    after_update :broadcast_update

    def broadcast_event(type)
      event_class = self.class.to_s
      channel = event_class.pluralize.underscore
      object_data = attributes.delete_if { |k, _| AppConfig['sensitive_fields'].include? "#{channel}.#{k}" }
      extended = respond_to?(:extended_websocket) ? extended_websocket : {}
      object_data.deep_merge! extended
      ApiChannel.broadcast_to channel, event_type: type, event_class: event_class, object: object_data
    end

    def broadcast_create
      broadcast_event 'create'
    end

    def broadcast_update
      broadcast_event 'update'
    end
  end
end
{'fraction_non_alphanumeric': 0.07643312101910828, 'fraction_numerical': 0.0, 'mean_word_length': 3.8940809968847354, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3288039', 'n_tokens_mistral': 480, 'n_tokens_neox': 465, 'n_words': 102}