<commit_before>module JSONAPI
  class Operation
    attr_reader :resource_klass, :options, :transactional

    def initialize(resource_klass, options = {})
      @resource_klass = resource_klass
      @options = options
      @transactional = true
    end

    def apply(context)
    end
  end

  class FindOperation < Operation
    attr_reader :filters, :include_directives, :sort_criteria, :paginator

    def initialize(resource_klass, options = {})
      @filters = options.fetch(:filters, nil)
      @include_directives = options.fetch(:include_directives, nil)
      @sort_criteria = options.fetch(:sort_criteria, nil)
      @paginator = options.fetch(:paginator, nil)
      super(resource_klass, false)
    end

    def apply(context)
      resource_records = @resource_klass.find(@resource_klass.verify_filters(@filters, context),
                                             context: context,
                                             include_directives: @include_directives,
                                             sort_criteria: @sort_criteria,
                                             paginator: @paginator)

      return JSONAPI::ResourcesOperationResult.new(:ok, resource_records)

    rescue JSONAPI::Exceptions::Error => e
      return JSONAPI::ErrorsOperationResult.new(e.errors[0].code, e.errors)
    end
  end
<commit_msg>Simplify extracting options that may be nil.<commit_after>module JSONAPI
  class Operation
    attr_reader :resource_klass, :options, :transactional

    def initialize(resource_klass, options = {})
      @resource_klass = resource_klass
      @options = options
      @transactional = true
    end

    def apply(context)
    end
  end

  class FindOperation < Operation
    attr_reader :filters, :include_directives, :sort_criteria, :paginator

    def initialize(resource_klass, options = {})
      @filters = options[:filters]
      @include_directives = options[:include_directives]
      @sort_criteria = options[:sort_criteria]
      @paginator = options[:paginator]
      super(resource_klass, false)
    end

    def apply(context)
      resource_records = @resource_klass.find(@resource_klass.verify_filters(@filters, context),
                                             context: context,
                                             include_directives: @include_directives,
                                             sort_criteria: @sort_criteria,
                                             paginator: @paginator)

      return JSONAPI::ResourcesOperationResult.new(:ok, resource_records)

    rescue JSONAPI::Exceptions::Error => e
      return JSONAPI::ErrorsOperationResult.new(e.errors[0].code, e.errors)
    end
  end

{'fraction_non_alphanumeric': 0.08280727812848125, 'fraction_numerical': 0.0007426661715558856, 'mean_word_length': 2.3507462686567164, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2325858', 'n_tokens_mistral': 674, 'n_tokens_neox': 678, 'n_words': 146}