<commit_before>module ResourceKit
  class ActionInvoker
    attr_reader :action, :connection, :args, :options

    attr_accessor :context

    def initialize(action, connection, *args)
      @action = action
      @connection = connection
      @args = args
      @options = args.last.kind_of?(Hash) ? args.last : {}
    end

    def self.call(action, connection, *args)
      new(action, connection, *args).handle_response
    end

    def handle_response
      if handler = action.handlers[response.status]
        handler.call(response)<commit_msg>Use instance exec for handler calls.<commit_after>module ResourceKit
  class ActionInvoker
    attr_reader :action, :connection, :args, :options

    attr_accessor :context

    def initialize(action, connection, *args)
      @action = action
      @connection = connection
      @args = args
      @options = args.last.kind_of?(Hash) ? args.last : {}
    end

    def self.call(action, connection, *args)
      new(action, connection, *args).handle_response
    end

    def handle_response
      if handler = action.handlers[response.status]
        context.instance_exec(response, &handler)
{'fraction_non_alphanumeric': 0.09702797202797203, 'fraction_numerical': 0.0, 'mean_word_length': 3.2095588235294117, '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': '5267110', 'n_tokens_mistral': 327, 'n_tokens_neox': 319, 'n_words': 83}