<commit_before># encoding: utf-8

module Adamantium

  # Methods mixed in to adamantium modules
  module ModuleMethods

    # Hook called when module is included
    #
    # @param [Module] mod
    #   the module including ModuleMethods
    #
    # @return [self]
    #
    # @api private
    def included(mod)
      Adamantium.included(mod)
      self
    end

    # Return default deep freezer
    #
    # @return [Freezer::Deep]
    #
    # @api private
    #
    def freezer
      Freezer::Deep
    end

    # Memoize a list of methods
    #
    # @example
    #   memoize :hash
    #
    # @param [Array<#to_s>] methods
    #   a list of methods to memoize
    #
    # @return [self]
    #
    # @api public
    def memoize(*methods)
      options        = methods.last.kind_of?(Hash) ? methods.pop : {}
      method_freezer = Freezer.parse(options) || freezer
      methods.each { |method| memoize_method(method, method_freezer) }
      self
    end

    # Return original instance method
    #
    # @example
    #
    #   class Foo
    #     include Adamantium
    #
    #     def bar
    #     end
    #     memoize :bar
    #
    #   end
    #
    #   Foo.original_instance_method(:bar) #=> UnboundMethod, where source_location still points to original!
    #
    # @param [Symbol] name
    #
    # @return [UnboundMethod]
    #   if method was memoized before
    #
    # @raise [ArgumentError]
    #   otherwise
    #
    # @api public
    #
    def original_instance_method(name)
      memoized_methods.fetch(name)
    end

  private

    # Memoize the named method
    #
    # @param [#to_s] method_name
    #   a method name to memoize
    # @param [#call] freezer<commit_msg>Use Hash#[] to trigger default proc<commit_after># encoding: utf-8

module Adamantium

  # Methods mixed in to adamantium modules
  module ModuleMethods

    # Hook called when module is included
    #
    # @param [Module] mod
    #   the module including ModuleMethods
    #
    # @return [self]
    #
    # @api private
    def included(mod)
      Adamantium.included(mod)
      self
    end

    # Return default deep freezer
    #
    # @return [Freezer::Deep]
    #
    # @api private
    #
    def freezer
      Freezer::Deep
    end

    # Memoize a list of methods
    #
    # @example
    #   memoize :hash
    #
    # @param [Array<#to_s>] methods
    #   a list of methods to memoize
    #
    # @return [self]
    #
    # @api public
    def memoize(*methods)
      options        = methods.last.kind_of?(Hash) ? methods.pop : {}
      method_freezer = Freezer.parse(options) || freezer
      methods.each { |method| memoize_method(method, method_freezer) }
      self
    end

    # Return original instance method
    #
    # @example
    #
    #   class Foo
    #     include Adamantium
    #
    #     def bar
    #     end
    #     memoize :bar
    #
    #   end
    #
    #   Foo.original_instance_method(:bar) #=> UnboundMethod, where source_location still points to original!
    #
    # @param [Symbol] name
    #
    # @return [UnboundMethod]
    #   if method was memoized before
    #
    # @raise [ArgumentError]
    #   otherwise
    #
    # @api public
    #
    def original_instance_method(name)
      memoized_methods[name]
    end

  private

    # Memoize the named method
    #
    # @param [#to_s] method_name
    #   a method name to memoize
    # @param [#call] freezer
{'fraction_non_alphanumeric': 0.0924072984108299, 'fraction_numerical': 0.0005885815185403178, 'mean_word_length': 1.978965819456617, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2864704', 'n_tokens_mistral': 1108, 'n_tokens_neox': 1077, 'n_words': 284}