<commit_before>module LazyColumns
  module ActsAsLazyColumnLoader
    extend ActiveSupport::Concern

    module ClassMethods
      def lazy_load(column_or_columns)
        lazy_columns = as_array_of_strings column_or_columns
        exclude_columns_from_default_scope lazy_columns
        make_columns_lazy_loadable lazy_columns
      end

      private

      def as_array_of_strings(element_or_elements)
        array = element_or_elements.respond_to?(:each) ? element_or_elements : [element_or_elements]
        array.collect(&:to_s)
      end

      def exclude_columns_from_default_scope(columns)
        default_scope select((column_names - columns).map { |column_name| "`#{table_name}`.`#{column_name}`" })
      end

      def make_columns_lazy_loadable(columns)
        columns.each { |column| define_lazy_load_method_for column }
      end

      def define_lazy_load_method_for(column)
        define_method column do
          self.reload select: column
          read_attribute column
        end
      end
    end
  end
end

#module ActiveRecord
#  class Base
#    def self.lazy_load(comments)
#      "ADIOS"
#    end
#  end
#end

if ActiveRecord::Base.respond_to?(:lazy_load)
  $stderr.puts "ERROR: Method `.lazy_load` already defined in `ActiveRecord::Base`. This is incompatible with LazyColumns and the plugin will be disabled."
else
  include LazyColumns::ActsAsLazyColumnLoader
end

<commit_msg>removing debug code<commit_after>module LazyColumns
  module ActsAsLazyColumnLoader
    extend ActiveSupport::Concern

    module ClassMethods
      def lazy_load(column_or_columns)
        lazy_columns = as_array_of_strings column_or_columns
        exclude_columns_from_default_scope lazy_columns
        make_columns_lazy_loadable lazy_columns
      end

      private

      def as_array_of_strings(element_or_elements)
        array = element_or_elements.respond_to?(:each) ? element_or_elements : [element_or_elements]
        array.collect(&:to_s)
      end

      def exclude_columns_from_default_scope(columns)
        default_scope select((column_names - columns).map { |column_name| "`#{table_name}`.`#{column_name}`" })
      end

      def make_columns_lazy_loadable(columns)
        columns.each { |column| define_lazy_load_method_for column }
      end

      def define_lazy_load_method_for(column)
        define_method column do
          self.reload(select: column)
          read_attribute column
        end
      end
    end
  end
end

if ActiveRecord::Base.respond_to?(:lazy_load)
  $stderr.puts "ERROR: Method `.lazy_load` already defined in `ActiveRecord::Base`. This is incompatible with LazyColumns and the plugin will be disabled."
else
  include LazyColumns::ActsAsLazyColumnLoader
end


{'fraction_non_alphanumeric': 0.06664225558403515, 'fraction_numerical': 0.0, 'mean_word_length': 3.4786885245901638, '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': '4369806', 'n_tokens_mistral': 835, 'n_tokens_neox': 821, 'n_words': 175}