<commit_before>module ActiveRecord
  module Acts #:nodoc:
    module HumanName #:nodoc:
      def self.included(base)
        base.extend(ClassMethods)
      end

      # This +acts_as+ extension provides the capabilities rendering different representations of a 
      # human name in English. Models need to store last_name, first_name, middle_name, and suffix columns
      # for this plugin to work.
      
      module ClassMethods
        # Configuration options are:
        #
        # * +last_name+ - specifies where the last name is stored (default: +last_name+)
        # * +first_name+ - specifies where the first name is stored (default: +first_name+)
        # * +middle_name+ - specifies where the middle name is stored (default: +middle_name+)
        # * +suffix+ - specifies where the suffix is stored (default: +suffix+)
        #   Example: <tt>acts_as_human_name :last_name => "surname"</tt>
        # HEY!!! This configuration stuff doesn't actually work yet!!!
        def acts_as_human_name(options = {})
          configuration = { :last_name => "last_name", 
                            :first_name => "first_name", 
                            :middle_name => "middle_name",
                            :suffix => "suffix" }
                            
          configuration.update(options) if options.is_a?(Hash)

          class_eval <<-EOV
            include ActiveRecord::Acts::HumanName::InstanceMethods

            def acts_as_human_name_class
              ::#{self.name}
            end

            
          EOV
        end
      end

      module InstanceMethods
        def regular_name
          if first_name and last_name
            "#{self.first_name} #{self.last_name}"
          elsif first_name
            first_name
          elsif last_name
            last_name
          end
        end

        def full_name
          if first_name and last_name and middle_name and suffix
            "#{last_name}, #{first_name} #{middle_name} #{suffix}"
          elsif first_name and last_name and middle_name
            "#{last_name}, #{first_name} #{middle_name}"
          elsif first_name and last_name and suffix
            "#{last_name}, #{first_name} #{suffix}"
          elsif first_name and last_name
            "#{last_name}, #{first_name}"
          elsif last_name
            last_name
          elsif first_name
            first_name
          end
        end<commit_msg>use include instead of class_eval<commit_after>module ActiveRecord
  module Acts #:nodoc:
    module HumanName #:nodoc:
      def self.included(base)
        base.extend(ClassMethods)
      end

      # This +acts_as+ extension provides the capabilities rendering different representations of a 
      # human name in English. Models need to store last_name, first_name, middle_name, and suffix columns
      # for this plugin to work.
      
      module ClassMethods
        # Configuration options are:
        #
        # * +last_name+ - specifies where the last name is stored (default: +last_name+)
        # * +first_name+ - specifies where the first name is stored (default: +first_name+)
        # * +middle_name+ - specifies where the middle name is stored (default: +middle_name+)
        # * +suffix+ - specifies where the suffix is stored (default: +suffix+)
        #   Example: <tt>acts_as_human_name :last_name => "surname"</tt>
        # HEY!!! This configuration stuff doesn't actually work yet!!!
        def acts_as_human_name(options = {})
          unless included_modules.include? InstanceMethods
            include ActiveRecord::Acts::HumanName::InstanceMethods

            def acts_as_human_name_class
              #{self.name}
            end
          end

          configuration = { :last_name => "last_name", 
                            :first_name => "first_name", 
                            :middle_name => "middle_name",
                            :suffix => "suffix" }
                            
          configuration.update(options) if options.is_a?(Hash)
        end
      end

      module InstanceMethods
        def regular_name
          if first_name and last_name
            "#{self.first_name} #{self.last_name}"
          elsif first_name
            first_name
          elsif last_name
            last_name
          end
        end

        def full_name
          if first_name and last_name and middle_name and suffix
            "#{last_name}, #{first_name} #{middle_name} #{suffix}"
          elsif first_name and last_name and middle_name
            "#{last_name}, #{first_name} #{middle_name}"
          elsif first_name and last_name and suffix
            "#{last_name}, #{first_name} #{suffix}"
          elsif first_name and last_name
            "#{last_name}, #{first_name}"
          elsif last_name
            last_name
          elsif first_name
            first_name
          end
        end
{'fraction_non_alphanumeric': 0.08049724882820461, 'fraction_numerical': 0.0, 'mean_word_length': 1.880281690140845, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, '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': '3612527', 'n_tokens_mistral': 1323, 'n_tokens_neox': 1281, 'n_words': 378}