<commit_before>class FromYaml

  # cattr_accessor would be cause children's implementations to conflict w/each other
  class << self
    attr_accessor :cache_key
  end
  
  attr_accessor :slug

  # Class Methods

  # called from the initializers/training_content.rb
  def self.load(args)
    collection = []

    self.cache_key = args[:cache_key]

    Dir.glob(args[:path_to_yaml]) do |yaml_file|
      slug = File.basename(yaml_file, ".yml")
      content = YAML.load_file(yaml_file).to_hashugar
      collection << self.new(content, slug)
    end
    Rails.cache.write args[:cache_key], collection
  end

  def self.all<commit_msg>if cache is empty, reload<commit_after>class FromYaml

  # cattr_accessor would be cause children's implementations to conflict w/each other
  class << self
    attr_accessor :cache_key, :path_to_yaml
  end
  
  attr_accessor :slug

  # Class Methods

  # called from the initializers/training_content.rb
  def self.load(args)
    collection = []

    self.cache_key = args[:cache_key]
    self.path_to_yaml = args[:path_to_yaml]

    Dir.glob(self.path_to_yaml) do |yaml_file|
      slug = File.basename(yaml_file, ".yml")
      content = YAML.load_file(yaml_file).to_hashugar
      collection << self.new(content, slug)
    end
    Rails.cache.write args[:cache_key], collection
  end

  def self.all
    if Rails.cache.read(self.cache_key).nil?
      self.load(self.cache_key, self.path_to_yaml)
    end
{'fraction_non_alphanumeric': 0.09520500347463516, 'fraction_numerical': 0.0, 'mean_word_length': 3.485981308411215, 'pattern_counts': {'":': 0, '<': 11, '<?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': '1598911', 'n_tokens_mistral': 501, 'n_tokens_neox': 476, 'n_words': 107}