<commit_before>require "method_cachable/version"
require "method_cachable/helper"

module MethodCachable

	include MethodCachable::Helper

  extend ActiveSupport::Concern

  included do
    def clear_cache
      Cachable.flush_cache cache_list_key
      Cachable.flush_cache "cache_list_key:#{self.class.name}"
      Cachable.flush_cache "cache_list_key:#{self.class.superclass.name}"
    end

    def cache_list_key
      "cache_list_key:#{self.class.name}:#{self.id}"
    end
  end

  module ClassMethods

    def acts_as_cachable
      klass = self
      [:after_touch, :before_destroy, :after_save].each { |callback| klass.send(callback, :clear_cache) }
    end

    def cached_methods(*methods)
      name = self.name
      eval_string = ""
      methods.each do |method|
        method = method.to_s
        eval_string += "
          alias_method :old_#{method}, :#{method}

          def #{method}(*args)
            sig = createsig(args || self.id)
            Cachable.with_env \"#{name}:#{method}:\#{self.id}:\#{sig}\", cache_list_key do
              old_#{method}(*args)
            end
          end<commit_msg>-Fixed code after local testing<commit_after>require "method_cachable/version"
require "method_cachable/helper"

module MethodCachable

	include MethodCachable::Helper

  extend ActiveSupport::Concern

  included do
    def clear_cache
      flush_cache cache_list_key
      flush_cache "cache_list_key:#{self.class.name}"
      flush_cache "cache_list_key:#{self.class.superclass.name}"
    end

    def cache_list_key
      "cache_list_key:#{self.class.name}:#{self.id}"
    end
  end

  module ClassMethods

    def acts_as_cachable
      klass = self
      [:after_touch, :before_destroy, :after_save].each { |callback| klass.send(callback, :clear_cache) }
    end

    def cached_methods(*methods)
      name = self.name
      eval_string = ""
      methods.each do |method|
        method = method.to_s
        eval_string += "
          alias_method :old_#{method}, :#{method}

          def #{method}(*args)
            sig = createsig(args || self.id)
            with_env \"#{name}:#{method}:\#{self.id}:\#{sig}\", cache_list_key do
              old_#{method}(*args)
            end
          end
{'fraction_non_alphanumeric': 0.11603942652329749, 'fraction_numerical': 0.0, 'mean_word_length': 2.759259259259259, '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': '4295664', 'n_tokens_mistral': 720, 'n_tokens_neox': 718, 'n_words': 133}