<commit_before>class Device
  include Mongoid::Document
  include Mongoid::Timestamps
  field :name
  field :device_name
  field :device_type
  embedded_in :User, :inverse_of => :devices

  @@after_save_procs = []
  def self.add_after_save(proc)
    @@after_save_procs << proc
  end
  after_save do |device|
    @@after_save_procs.each do |proc|
      proc.call(device)
    end
  end

  @@after_destory_procs = []
  def self.add_after_destroy(proc)
    @@after_destory_procs << proc
  end
  after_destroy do |device|
    @@after_destory_procs.each do |proc|
      proc.call(device)
    end
  end
end<commit_msg>Refactored: remove code clone refs #191<commit_after>class Device
  include Mongoid::Document
  include Mongoid::Timestamps
  field :name
  field :device_name
  field :device_type
  embedded_in :User, :inverse_of => :devices

  def self.register_callback(event)
    class_eval <<-EOS
      @@#{event.to_s}_procs = []
      def self.add_#{event.to_s}(proc)
        @@#{event.to_s}_procs << proc
      end
      #{event.to_s} do |device|
        @@#{event.to_s}_procs.each do |proc|
          proc.call(device)
        end
      end
    EOS
  end
  register_callback :after_save
  register_callback :after_destroy

end
{'fraction_non_alphanumeric': 0.10431947840260798, 'fraction_numerical': 0.0024449877750611247, 'mean_word_length': 3.323943661971831, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, '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': '3352046', 'n_tokens_mistral': 444, 'n_tokens_neox': 432, 'n_words': 93}