<commit_before># SuperModule allows defining class methods and method invocations the same way a super class does without using def included(base).
#
# Author::    <NAME>
# Copyright:: Copyright (c) 2014 <NAME>
# License::   MIT License

# This module allows defining class methods and method invocations the same way a super class does without using def included(base).

module SuperModule
  def self.included(base)
    base.class_eval do
      class << self

        def include(base, &block)
          method_missing('include', base, &block)
        end

        def __super_module_class_method_invocations
          @__super_module_class_method_invocations ||= []
        end

        def __super_module_class_methods
          @__super_module_class_methods ||= []
        end

        def singleton_method_added(method_name)
          __super_module_class_methods << [method_name, method(method_name)] unless [:__super_module_class_methods, :included, :method_missing, :singleton_method_added].include?(method_name)
          super
        end

        def method_missing(method_name, *args, &block)
          __super_module_class_method_invocations << [method_name, args, block]
        end

        def included(base)
          __super_module_class_method_invocations.each do |method_name, args, block|
            base.class_eval do
              send(method_name, *args, &block)
            end
          end
          __super_module_class_methods.each do |method_name, method|
            base.class_eval do
              self.class.send(:define_method, method_name, &method)
            end
          end
          base.class_eval do
            class << self
              def method_missing(method_name, *args, &block)
                super
              end
            end
          end
        end
      end
    end
  end
end<commit_msg>Refactored SuperModule extracting methods with friendly names and a constant that holds array of excluded singleton method names<commit_after># SuperModule allows defining class methods and method invocations the same way a super class does without using def included(base).
#
# Author::    <NAME>
# Copyright:: Copyright (c) 2014 <NAME>
# License::   MIT License

# This module allows defining class methods and method invocations the same way a super class does without using def included(base).

module SuperModule
  EXCLUDED_SINGLETON_METHODS = [
    :__super_module_class_methods,
    :__invoke_super_module_class_method_calls,
    :__define_super_module_class_methods,
    :__restore_original_method_missing,
    :included, :method_missing,
    :singleton_method_added
  ]
  def self.included(base)
    base.class_eval do
      class << self

        def include(base, &block)
          method_missing('include', base, &block)
        end

        def __super_module_class_method_calls
          @__super_module_class_method_calls ||= []
        end

        def __super_module_class_methods
          @__super_module_class_methods ||= []
        end

        def singleton_method_added(method_name)
          __super_module_class_methods << [method_name, method(method_name)] unless EXCLUDED_SINGLETON_METHODS.include?(method_name)
          super
        end

        def method_missing(method_name, *args, &block)
          __super_module_class_method_calls << [method_name, args, block]
        end

        def __invoke_super_module_class_method_calls(base)
          __super_module_class_method_calls.each do |method_name, args, block|
            base.class_eval do
              send(method_name, *args, &block)
            end
          end
        end

        def __define_super_module_class_methods(base)
          __super_module_class_methods.each do |method_name, method|
            base.class_eval do
              self.class.send(:define_method, method_name, &method)
            end
          end
        end

        def included(base)
          __invoke_super_module_class_method_calls(base)
          __define_super_module_class_methods(base)
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.06351550960118169, 'fraction_numerical': 0.0019694731659281144, 'mean_word_length': 2.601950354609929, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 7, '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': '5068439', 'n_tokens_mistral': 1140, 'n_tokens_neox': 1111, 'n_words': 289}