<commit_before>module ActionSubscriber
  module Middleware
    class Router
      def initialize(app)
        @app = app
      end

      def call(env)
        subscriber = env.subscriber.new(env)

        # TODO: Figure out if we should be checking this
        #
        subscriber.__send__(env.action) if subscriber.respond_to?(env.action)

      # TODO: Extract error handling into a middleware
      #
      rescue => exception
        ::ActionSubscriber.configuration.error_handler.call(exception)
      end
    end
  end
end<commit_msg>Deprecate passing the payload to subscribable actions<commit_after>module ActionSubscriber
  module Middleware
    class Router
      def initialize(app)
        @app = app
      end

      def call(env)
        subscriber = env.subscriber.new(env)

        # TODO: Figure out if we should be checking this
        #
        if subscriber.respond_to?(env.action)
          action = subscriber.method(env.action)

          # TODO: Remove this check in 1.0
          if action.arity == 0
            action.call
          else
            warn 'DEPRECATED passing the payload to subscribable methods is deprecated and will be removed in Action Subscriber 1.0. Use the :payload attribute in the subscriber instead.'
            action.call(env.payload)
          end
        end

      # TODO: Extract error handling into a middleware
      #
      rescue => exception
        ::ActionSubscriber.configuration.error_handler.call(exception)
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.0623342175066313, 'fraction_numerical': 0.0033156498673740055, 'mean_word_length': 2.1701680672268906, 'pattern_counts': {'":': 0, '<': 3, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7475655', 'n_tokens_mistral': 405, 'n_tokens_neox': 389, 'n_words': 128}