<commit_before>class Settings < ActiveRecord::Base
  class SettingNotFound < RuntimeError; end
  
  cattr_accessor :defaults
  self.defaults = {}.with_indifferent_access

  #get or set a variable with the variable as the called method
  def self.method_missing(method, *args)
    if self.respond_to?(method)
      super
    else
      method_name = method.to_s
    
      #set a value for a variable
      if method_name =~ /=$/
        var_name = method_name.gsub('=', '')<commit_msg>Use Thread.current instead of cattr_accessor to be threadsafe<commit_after>class Settings < ActiveRecord::Base
  class SettingNotFound < RuntimeError; end
  
  def self.defaults
    Thread.current[:rails_settings_defaults] ||= {}.with_indifferent_access
  end
  
  def self.defaults=(value)
    Thread.current[:rails_settings_defaults] = value
  end

  #get or set a variable with the variable as the called method
  def self.method_missing(method, *args)
    if self.respond_to?(method)
      super
    else
      method_name = method.to_s
    
      #set a value for a variable
      if method_name =~ /=$/
        var_name = method_name.gsub('=', '')
{'fraction_non_alphanumeric': 0.08875219683655536, 'fraction_numerical': 0.0, 'mean_word_length': 3.281954887218045, 'pattern_counts': {'":': 0, '<': 7, '<?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': '3926646', 'n_tokens_mistral': 345, 'n_tokens_neox': 342, 'n_words': 97}