<commit_before>module Api
  class BaseController
    module Generic
      #
      # Primary Methods
      #

      def show
        if @req.subcollection
          render_collection_type @req.subcollection.to_sym, @req.s_id, true
        else
          render_collection_type @req.collection.to_sym, @req.c_id
        end
      end

      def update
        if @req.subcollection
          render_normal_update @req.collection.to_sym, update_collection(@req.subcollection.to_sym, @req.s_id, true)
        else
          render_normal_update @req.collection.to_sym, update_collection(@req.collection.to_sym, @req.c_id)
        end
      end

      def destroy
        if @req.subcollection
          delete_subcollection_resource @req.subcollection.to_sym, @req.s_id
        else
          send(target_resource_method(false, @req.collection.to_sym, :delete), @req.collection.to_sym, @req.c_id)
        end
        render_normal_destroy
      end

      #
      # Action Helper Methods
      #
      # Name: <action>_resource
      # Args: collection type, resource id, optional data
      #
      # For type specified, name is <action>_resource_<collection>
      # Same signature.
      #
      def add_resource(type, _id, data)
        assert_id_not_specified(data, "#{type} resource")
        klass = collection_class(type)
        subcollection_data = collection_config.subcollections(type).each_with_object({}) do |sc, hash|
          if data.key?(sc.to_s)<commit_msg>Eliminate send call in destroy<commit_after>module Api
  class BaseController
    module Generic
      #
      # Primary Methods
      #

      def show
        if @req.subcollection
          render_collection_type @req.subcollection.to_sym, @req.s_id, true
        else
          render_collection_type @req.collection.to_sym, @req.c_id
        end
      end

      def update
        if @req.subcollection
          render_normal_update @req.collection.to_sym, update_collection(@req.subcollection.to_sym, @req.s_id, true)
        else
          render_normal_update @req.collection.to_sym, update_collection(@req.collection.to_sym, @req.c_id)
        end
      end

      def destroy
        if @req.subcollection
          delete_subcollection_resource @req.subcollection.to_sym, @req.s_id
        else
          delete_resource(@req.collection.to_sym, @req.c_id)
        end
        render_normal_destroy
      end

      #
      # Action Helper Methods
      #
      # Name: <action>_resource
      # Args: collection type, resource id, optional data
      #
      # For type specified, name is <action>_resource_<collection>
      # Same signature.
      #
      def add_resource(type, _id, data)
        assert_id_not_specified(data, "#{type} resource")
        klass = collection_class(type)
        subcollection_data = collection_config.subcollections(type).each_with_object({}) do |sc, hash|
          if data.key?(sc.to_s)
{'fraction_non_alphanumeric': 0.08356258596973865, 'fraction_numerical': 0.0, 'mean_word_length': 2.359122401847575, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '3129460', 'n_tokens_mistral': 872, 'n_tokens_neox': 864, 'n_words': 180}