<commit_before>
module ActiveRecord
  class Base
    class << self
      def encrypt(attr_name)
        attr_name = attr_name.to_s
        define_method("encrypt_#{attr_name}") do
          if self.attribute_names.include?("#{attr_name}") ? eval("self.#{attr_name}_changed?") : true
            eval("self.#{attr_name} = ArEncrypt.encrypt(\"#{eval("self.#{attr_name}")}\")")
          end
          return true
        end
        define_method("#{attr_name}_match?") do |match_str|
          return eval("self.#{attr_name} == ArEncrypt.encrypt(\"#{eval("match_str")}\")")
        end
        class_eval do
          eval("def self.#{attr_name}_find(str); find_by_#{attr_name}(ArEncrypt.encrypt(str)); end;")
        end
        class_eval do
          eval("def self.#{attr_name}_find_all(str); find(:all, :conditions=>[\"#{attr_name} = ?\", ArEncrypt.encrypt(str)]); end;")<commit_msg>added other params for finds<commit_after>
module ActiveRecord
  class Base
    class << self
      def encrypt(attr_name)
        attr_name = attr_name.to_s
        define_method("encrypt_#{attr_name}") do
          if self.attribute_names.include?("#{attr_name}") ? eval("self.#{attr_name}_changed?") : true
            eval("self.#{attr_name} = ArEncrypt.encrypt(\"#{eval("self.#{attr_name}")}\")")
          end
          return true
        end
        define_method("#{attr_name}_match?") do |match_str|
          return eval("self.#{attr_name} == ArEncrypt.encrypt(\"#{eval("match_str")}\")")
        end
        class_eval do
          eval("def self.#{attr_name}_find(str, options = {})
          conditions_array = ['1 = 1']
          options.each_pair do |key, value|
            conditions_array << \"\#{key} = '\#{value}'\"
          end
          if conditions_array.length > 0
            conditions_str = \" and \#{conditions_array.join(' and ')}\"
          else
            conditions_str = ''
          end
          find(:first, :conditions=>[\"#{attr_name} = ? \#{conditions_str}\", ArEncrypt.encrypt(str)])
          end")
        end
        class_eval do
          eval("def self.#{attr_name}_find_all(str, options = {})
          conditions_array = []
          options.each_pair do |key, value|
            conditions_array << \"\#{key} = '\#{value}'\"
          end
          if conditions_array.length > 0
            conditions_str = \" and \#{conditions_array.join(' and ')}\"
          else
            conditions_str = ''
          end
          find(:all, :conditions=>[\"#{attr_name} = ? \#{conditions_str}\", ArEncrypt.encrypt(str)])
          end")
{'fraction_non_alphanumeric': 0.16374951380785688, 'fraction_numerical': 0.0015558148580318942, 'mean_word_length': 2.335927367055772, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 8, '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': '5978455', 'n_tokens_mistral': 787, 'n_tokens_neox': 813, 'n_words': 139}