<commit_before>module ApiCachedAttributes
  # A storage entry closely resembles a network response. This seeks to
  # counteract the impedance mismatch because API responses are done on the
  # resource level and we want to query storages at the attribute level. Headers
  # are also handled on the resource (response) level as well, and thus apply
  # for many attributes.
  class StorageEntry
    def self.from_response(response)
      new(response.headers, response.data)
    end

    attr_reader :headers, :data

    def initialize(headers, data)
      @headers = headers || {}
      @data = data || {}
    end
  end
end<commit_msg>to_hash method for storage entry<commit_after>module ApiCachedAttributes
  # A storage entry closely resembles a network response. This seeks to
  # counteract the impedance mismatch because API responses are done on the
  # resource level and we want to query storages at the attribute level. Headers
  # are also handled on the resource (response) level as well, and thus apply
  # for many attributes.
  class StorageEntry
    def self.from_response(response)
      new(response.headers, response.data)
    end

    attr_reader :headers, :data

    def initialize(headers, data)
      @headers = headers.try(:to_hash) || {}
      @data = data.try(:to_hash) || {}
    end

    def to_hash
      {
        data: @data,
        headers: @headers
      }
    end
  end
end
{'fraction_non_alphanumeric': 0.06751954513148543, 'fraction_numerical': 0.0, 'mean_word_length': 3.1533923303834808, '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': '5136022', 'n_tokens_mistral': 386, 'n_tokens_neox': 374, 'n_words': 156}