<commit_before># frozen_string_literal: true
module Pragma
  module Rails
    # This mixin should be included in a Rails controller to provide integration with Pragma
    # operations.
    #
    # @author <NAME>
    module Controller
      def self.included(klass)
        klass.include InstanceMethods
      end

      module InstanceMethods # :nodoc:
        # Runs an operation, then responds with the returned status code, headers and resource.
        #
        # @param operation_klass [Class] a subclass of +Pragma::Operation::Base+
        def run(operation_klass)
          result = operation_klass.call(
            params: operation_params,
            current_user: operation_user
          )

          result.headers.each_pair do |key, value|<commit_msg>Make Controller#run accept a string as well as a constant<commit_after># frozen_string_literal: true
module Pragma
  module Rails
    # This mixin should be included in a Rails controller to provide integration with Pragma
    # operations.
    #
    # @author <NAME>
    module Controller
      def self.included(klass)
        klass.include InstanceMethods
      end

      module InstanceMethods # :nodoc:
        # Runs an operation, then responds with the returned status code, headers and resource.
        #
        # @param operation_klass [Class|String] a subclass of +Pragma::Operation::Base+
        def run(operation_klass)
          result = operation_klass.to_s.constantize.call(
            params: operation_params,
            current_user: operation_user
          )

          result.headers.each_pair do |key, value|
{'fraction_non_alphanumeric': 0.06359102244389027, 'fraction_numerical': 0.0, 'mean_word_length': 2.5825892857142856, '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': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1338572', 'n_tokens_mistral': 417, 'n_tokens_neox': 415, 'n_words': 140}