<commit_before>require 'rawnet_admin/black_hole'

module RawnetAdmin
  module Resource
    module Helpers

      protected

      def collection
        get_collection_ivar || set_collection_ivar(end_of_association_chain)
      end

      def resource
        get_resource_ivar || set_resource_ivar(end_of_association_chain.find(params[:id]))
      end

      def build_resource
        get_resource_ivar || set_resource_ivar(end_of_association_chain.new(resource_params))
      end

      def create_resource(object)
        object.save
      end

      def update_resource(object, attributes)
        object.update(attributes)
      end

      def destroy_resource(object)
        object.destroy
      end

      def resource_class
        @resource_class ||= controller_name.classify.safe_constantize
      end

      private

      def end_of_association_chain
        apply_scopes_if_available(resource_class)
      end

      def get_resource_ivar
        instance_variable_get("@#{resource_instance_name}")
      end<commit_msg>Scope resource_class Calling #each etc would error<commit_after>require 'rawnet_admin/black_hole'

module RawnetAdmin
  module Resource
    module Helpers

      protected

      def collection
        get_collection_ivar || set_collection_ivar(end_of_association_chain)
      end

      def resource
        get_resource_ivar || set_resource_ivar(end_of_association_chain.find(params[:id]))
      end

      def build_resource
        get_resource_ivar || set_resource_ivar(end_of_association_chain.new(resource_params))
      end

      def create_resource(object)
        object.save
      end

      def update_resource(object, attributes)
        object.update(attributes)
      end

      def destroy_resource(object)
        object.destroy
      end

      def resource_class
        @resource_class ||= controller_name.classify.safe_constantize
      end

      private

      def end_of_association_chain
        apply_scopes_if_available(begin_of_association_chain)
      end

      def begin_of_association_chain
        resource_class.where(nil)
      end

      def get_resource_ivar
        instance_variable_get("@#{resource_instance_name}")
      end
{'fraction_non_alphanumeric': 0.051794638800545204, 'fraction_numerical': 0.0, 'mean_word_length': 2.8162911611785097, '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': '7231876', 'n_tokens_mistral': 647, 'n_tokens_neox': 629, 'n_words': 111}