<commit_before>module Mincer
  module Processors

    class Sort
      def initialize(mincer)
        @mincer, @args, @relation = mincer, mincer.args, mincer.relation
      end

      def apply
        relation = @relation.order(sort_string)
        @mincer.sort_attribute, @mincer.sort_order = relation.try(:order_values).try(:first).try(:split)
        relation
      end

      def sort_string
        sort_attr ? "#{sort_attr} #{order_attr}, #{@mincer.default_sort_attribute}" : "#{@mincer.default_sort_attribute} #{order_attr}"
      end

      def sort_attr
        @mincer.allowed_sort_attributes.include?(@args['sort']) && @args['sort']
      end

      def order_attr
        (%w{ASC DESC}.include?(@args['order']) && @args['order']) || @mincer.default_sort_order
      end
    end
<commit_msg>since subclasses can define "default_sort_(attribute|order)" and "allowed_sort_attributes" as private methods, we will start calling them with "send"<commit_after>module Mincer
  module Processors

    class Sort
      def initialize(mincer)
        @mincer, @args, @relation = mincer, mincer.args, mincer.relation
      end

      def apply
        relation = @relation.order(sort_string)
        @mincer.sort_attribute, @mincer.sort_order = relation.try(:order_values).try(:first).try(:split)
        relation
      end

      def sort_string
        sort_attr ? "#{sort_attr} #{order_attr}, #{@mincer.send(:default_sort_attribute)}" : "#{@mincer.send(:default_sort_attribute)} #{order_attr}"
      end

      def sort_attr
        @mincer.send(:allowed_sort_attributes).include?(@args['sort']) && @args['sort']
      end

      def order_attr
        (%w{ASC DESC}.include?(@args['order']) && @args['order']) || @mincer.send(:default_sort_order)
      end
    end

{'fraction_non_alphanumeric': 0.13333333333333333, 'fraction_numerical': 0.0, 'mean_word_length': 3.2674698795180723, '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': '7460799', 'n_tokens_mistral': 549, 'n_tokens_neox': 536, 'n_words': 108}