<commit_before>module ActiveModel
  class Serializer
    class ArraySerializer
      include Enumerable
      delegate :each, to: :@objects

      attr_reader :meta, :meta_key

      def initialize(objects, options = {})
        @objects = objects.map do |object|
          serializer_class = options.fetch(
            :serializer,
            ActiveModel::Serializer.serializer_for(object)
          )
          serializer_class.new(object, options.except(:serializer))
        end
        @meta     = options[:meta]
        @meta_key = options[:meta_key]
      end

      def json_key
        @objects.first.json_key.pluralize if @objects.first
      end

      def root=(root)
        @objects.first.root = root if @objects.first
      end
    end
  end
end
<commit_msg>Getting root key from AR::Relation<commit_after>module ActiveModel
  class Serializer
    class ArraySerializer
      include Enumerable
      delegate :each, to: :@objects

      attr_reader :meta, :meta_key

      def initialize(objects, options = {})
        @resource = objects
        @objects  = objects.map do |object|
          serializer_class = options.fetch(
            :serializer,
            ActiveModel::Serializer.serializer_for(object)
          )
          serializer_class.new(object, options.except(:serializer))
        end
        @meta     = options[:meta]
        @meta_key = options[:meta_key]
      end

      def json_key
        if @objects.first
          @objects.first.json_key.pluralize
        else
          @resource.name.downcase.pluralize if @resource.try(:name)
        end
      end

      def root=(root)
        @objects.first.root = root if @objects.first
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.08524397413286303, 'fraction_numerical': 0.0, 'mean_word_length': 2.072202166064982, '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': '7651882', 'n_tokens_mistral': 483, 'n_tokens_neox': 473, 'n_words': 111}