<commit_before>module Api
  class OptionsSerializer
    def self.serialize(klass, data = {})
      new(klass, data).serialize
    end

    attr_reader :klass, :data, :config

    def initialize(klass, data = {})
      @klass = klass
      @data = data
      @config = CollectionConfig.new
    end

    def serialize
      resource = config.name_for_klass(klass) if klass
      options = if klass
                  {
                    :attributes         => options_attribute_list(klass.attribute_names -
                                                                  klass.virtual_attribute_names),
                    :virtual_attributes => options_attribute_list(klass.virtual_attribute_names),
                    :relationships      => (klass.reflections.keys |
                                            klass.virtual_reflections.keys.collect(&:to_s)).sort
                  }
                else
                  {:attributes => [], :virtual_attributes => [], :relationships => []}
                end
      options[:subcollections] = Array(resource ? config[resource].subcollections : nil).sort
      options[:data] = data
      options
    end

    private

    def options_attribute_list(attrlist)
      attrlist.sort.select { |attr| !Api.encrypted_attribute?(attr) }
    end
  end
end<commit_msg>Extract private method attributes<commit_after>module Api
  class OptionsSerializer
    def self.serialize(klass, data = {})
      new(klass, data).serialize
    end

    attr_reader :klass, :data, :config

    def initialize(klass, data = {})
      @klass = klass
      @data = data
      @config = CollectionConfig.new
    end

    def serialize
      resource = config.name_for_klass(klass) if klass
      options = if klass
                  {
                    :attributes         => attributes,
                    :virtual_attributes => options_attribute_list(klass.virtual_attribute_names),
                    :relationships      => (klass.reflections.keys |
                                            klass.virtual_reflections.keys.collect(&:to_s)).sort
                  }
                else
                  {:attributes => attributes, :virtual_attributes => [], :relationships => []}
                end
      options[:subcollections] = Array(resource ? config[resource].subcollections : nil).sort
      options[:data] = data
      options
    end

    private

    def attributes
      return [] unless klass
      options_attribute_list(klass.attribute_names - klass.virtual_attribute_names)
    end

    def options_attribute_list(attrlist)
      attrlist.sort.select { |attr| !Api.encrypted_attribute?(attr) }
    end
  end
end
{'fraction_non_alphanumeric': 0.08933933933933934, 'fraction_numerical': 0.0, 'mean_word_length': 1.8320935175345376, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4213747', 'n_tokens_mistral': 670, 'n_tokens_neox': 678, 'n_words': 136}