<commit_before>class UserActionObserver < ActiveRecord::Observer
  observe User, Page, Layout, Snippet
  
  cattr_accessor :current_user
  
  def before_create(model)
    model.created_by = @@current_user
  end
  
  def before_update(model)
    model.updated_by = @@current_user
  end
end<commit_msg>thread safe user action observer<commit_after>class UserActionObserver < ActiveRecord::Observer
  observe User, Page, Layout, Snippet
  
  def self.current_user=(user)
    Thread.current[:current_user] = user
  end
  
  def self.current_user
    Thread.current[:current_user]
  end
  
  def before_create(model)
    model.created_by = self.class.current_user
  end
  
  def before_update(model)
    model.updated_by = self.class.current_user
  end
end
{'fraction_non_alphanumeric': 0.0758988015978695, 'fraction_numerical': 0.0, 'mean_word_length': 4.1506849315068495, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2535737', 'n_tokens_mistral': 241, 'n_tokens_neox': 240, 'n_words': 52}