<commit_before>class RockDoc
  module Interrogation
    class ActiveModelSerializer
      def self.interrogate_serialization doc: nil, resource_configuration: nil, configuration: nil
        configuration.serializer          = resource_configuration.serializer
        configuration.resource_class      = resource_configuration.resource_class
        configuration.resource_name       = resource_configuration.resource_class.name.underscore.humanize
        configuration.configuration_name  = resource_configuration.configuration_name
        configuration.attributes_for_json = serializer_to_attributes doc, configuration.serializer, configuration.resource_class
      end

      def self.serializer_to_attributes doc, serializer, resource_class
        attributes   = serializer.schema[:attributes].dup
        associations = serializer.schema.fetch(:associations, {}).reduce({}) { |memo, kvp|
          key = nil

          begin
            key = resource_class.reflect_on_association(kvp.first).class_name
          rescue NoMethodError
          end

          if key<commit_msg>Harden against errors surrounding non-model serializers<commit_after>class RockDoc
  module Interrogation
    class ActiveModelSerializer
      def self.interrogate_serialization doc: nil, resource_configuration: nil, configuration: nil
        configuration.serializer          = resource_configuration.serializer
        configuration.resource_class      = resource_configuration.resource_class
        begin
          configuration.resource_name     = resource_configuration.resource_class.name.underscore.humanize
        rescue NoMethodError
          configuration.resource_name     = resource_configuration.configuration_name.to_s.humanize
        end
        configuration.configuration_name  = resource_configuration.configuration_name
        configuration.attributes_for_json = serializer_to_attributes doc, configuration.serializer, configuration.resource_class
      end

      def self.serializer_to_attributes doc, serializer, resource_class
        attributes   = serializer.schema.fetch(:attributes, {}).dup
        associations = serializer.schema.fetch(:associations, {}).reduce({}) { |memo, kvp|
          key = nil

          begin
            key = resource_class.reflect_on_association(kvp.first).class_name
          rescue NoMethodError
          end

          if key
{'fraction_non_alphanumeric': 0.058007566204287514, 'fraction_numerical': 0.0, 'mean_word_length': 3.25, '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': '2270504', 'n_tokens_mistral': 559, 'n_tokens_neox': 553, 'n_words': 111}