<commit_before>require "genderize/gender"
require "genderize/engine"

unless Rails
  raise "Genderize is a Rails gem and expects to used in a Rails (3 or higher) application"
end

module Genderize

  def self.included(base)
    base.extend(ClassMethods)
  end

  module ClassMethods


    def genderize(col_name = "gender")
      # Reads the DB column value for gender attribute and creates a new Gender
      # object with it's value
      #
      # The object is memoized for future calls.
      #
      # Returns a Gender
      define_method col_name do
        current_value = instance_variable_get("@#{col_name}")
        persist_value = Genderize::Gender.new(read_attribute(col_name))
        return current_value || instance_variable_set("@#{col_name}", persist_value)
      end

      # Writes to the DB column the new value for the gender attribute
      # Sets the instance varaible value too
      #
      # string - A String indicating the gender. Must be either 'm', "M", 'f' or "F".
      #
      # Raises ArgumentError if gender is not a single alphanumeric character "m" or "f"
      define_method "#{col_name}=" do |string|
        string = string.to_s.first
        unless string.to_s =~ /\A(m|f|)\Z/i
          raise ArgumentError, "Gender must be one of '', 'm', or 'f'"
        end
        write_attribute(col_name, string)

        if string.blank?
          instance_variable_set("@#{col_name}", string)
        else
          instance_variable_set("@#{col_name}", Genderize::Gender.new(read_attribute(col_name)))
        end<commit_msg>Fixing broken test<commit_after>require "genderize/gender"
require "genderize/engine"

unless Rails
  raise "Genderize is a Rails gem and expects to used in a Rails (3 or higher) application"
end

module Genderize

  def self.included(base)
    base.extend(ClassMethods)
  end

  module ClassMethods


    def genderize(col_name = "gender")
      # Reads the DB column value for gender attribute and creates a new Gender
      # object with it's value
      #
      # The object is memoized for future calls.
      #
      # Returns a Gender
      define_method col_name do
        current_value = instance_variable_get("@#{col_name}")
        persist_value = Genderize::Gender.new(read_attribute(col_name))
        return current_value || instance_variable_set("@#{col_name}", persist_value)
      end

      # Writes to the DB column the new value for the gender attribute
      # Sets the instance varaible value too
      #
      # string - A String indicating the gender. Must be either 'm', "M", 'f' or "F".
      #
      # Raises ArgumentError if gender is not a single alphanumeric character "m" or "f"
      define_method "#{col_name}=" do |string|
        string = string.to_s.first
        unless string.to_s =~ /\A(m|f|)\Z/i
          raise ArgumentError, "Gender must be one of '', 'm', or 'f'"
        end
        write_attribute(col_name, string)

        instance_variable_set("@#{col_name}", Genderize::Gender.new(read_attribute(col_name)))
{'fraction_non_alphanumeric': 0.09313887968180312, 'fraction_numerical': 0.0006629101756711965, 'mean_word_length': 2.8692307692307693, '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': '4464279', 'n_tokens_mistral': 913, 'n_tokens_neox': 875, 'n_words': 293}