<commit_before># DO NOT EDIT: File is autogenerated
module <%= object_type.schema.ruby.module_name %>

class <%= object_type.ruby.classname %> < ActiveRecord::Base
  # Attributes:
<% object_type.attributes.select{|a| a.persistent?}.each do |a|
%>  #   <%= a.sql.column_name %>: <%= a.reference? ? a.referenced_object.name : a.attribute_type %>
<% end %>
  set_table_name "<%= sql_qualify(object_type.schema,object_type.sql.table_name).gsub('[','').gsub(']','').gsub('dbo.','') %>"
  set_primary_key "<%= object_type.primary_key.sql.column_name %>"
<% object_type.attributes.each do |a| %>
<%   if a.persistent? && a.validate?
       if !a.generated_value?
         if a.attribute_type == :i_enum
           a.values.each do |k,v|
%>  <%= a.name %>_<%= k %> = <%= v %>
<%         end
%>  validates_inclusion_of :<%= a.sql.column_name %>, :in => [<%= a.values.keys.collect{|k| "#{a.name}_#{k}"}.join(', ') %>]
<%
         end
         if !a.nullable? && a.attribute_type != :boolean
%>  validates_presence_of :<%= a.sql.column_name %>
<%       end
         if a.unique?
%>  validates_uniqueness_of :<%= a.sql.column_name %>
<%       end
         if a.attribute_type == :integer
%>  validates_numericality_of :<%= a.sql.column_name %>, :only_integer => true, :allow_nil => true
<%       end
         if a.attribute_type == :boolean
%>  validates_boolean :<%= a.sql.column_name %>, :allow_nil => <%= a.nullable? %>
<%       end
         if a.attribute_type == :string || a.attribute_type == :s_enum
%>  nillable_attribute :<%= a.sql.column_name %>
  validates_length_of :<%= a.sql.column_name %>, :maximum => <%= a.length %>, :allow_nil => true
<%       end
         if a.reference?
%>  belongs_to :<%= underscore(a.name) %>, :class_name => '<%= a.referenced_object.ruby.fully_qualified_name %>', :foreign_key => '<%= a.sql.column_name %>'
  validates_reference_exists :<%= a.sql.column_name %>, <%= a.referenced_object.ruby.fully_qualified_name %>, :association_name => :<%= underscore(a.name) %>, :allow_nil => true
<%       end
       end
     end
   end %>
<% object_type.referencing_attributes.each do |attribute|
    if attribute.inverse_relationship_type == :has_many
%>
  has_many :<%= pluralize(underscore(attribute.inverse_relationship_name)) %>, :class_name => '<%= attribute.object_type.ruby.fully_qualified_name %>', :foreign_key => '<%= attribute.sql.column_name %>', :dependent => :destroy
  has_count_of :<%= pluralize(underscore(attribute.inverse_relationship_name)) %>
<%
    end
    if attribute.inverse_relationship_type == :has_one
%>
  has_one :<%= underscore(attribute.inverse_relationship_name) %>, :class_name => '<%= attribute.object_type.ruby.fully_qualified_name %>', :foreign_key => '<%= attribute.sql.column_name %>'
<%
    end
  end
%>

  # Make it possible for the users to extend the model by defining an extenion class
  include <%= object_type.ruby.fully_qualified_name %>Extension rescue NameError
end

end<commit_msg>Improve the wordage<commit_after># DO NOT EDIT: File is autogenerated
module <%= object_type.schema.ruby.module_name %>

class <%= object_type.ruby.classname %> < ActiveRecord::Base
  # Attributes:
<% object_type.attributes.select{|a| a.persistent?}.each do |a|
%>  #   <%= a.sql.column_name %>: <%= a.reference? ? a.referenced_object.name : a.attribute_type %>
<% end %>
  set_table_name "<%= sql_qualify(object_type.schema,object_type.sql.table_name).gsub('[','').gsub(']','').gsub('dbo.','') %>"
  set_primary_key "<%= object_type.primary_key.sql.column_name %>"
<% object_type.attributes.each do |a| %>
<%   if a.persistent? && a.validate?
       if !a.generated_value?
         if a.attribute_type == :i_enum
           a.values.each do |k,v|
%>  <%= a.name %>_<%= k %> = <%= v %>
<%         end
%>  validates_inclusion_of :<%= a.sql.column_name %>, :in => [<%= a.values.keys.collect{|k| "#{a.name}_#{k}"}.join(', ') %>]
<%
         end
         if !a.nullable? && a.attribute_type != :boolean
%>  validates_presence_of :<%= a.sql.column_name %>
<%       end
         if a.unique?
%>  validates_uniqueness_of :<%= a.sql.column_name %>
<%       end
         if a.attribute_type == :integer
%>  validates_numericality_of :<%= a.sql.column_name %>, :only_integer => true, :allow_nil => true
<%       end
         if a.attribute_type == :boolean
%>  validates_boolean :<%= a.sql.column_name %>, :allow_nil => <%= a.nullable? %>
<%       end
         if a.attribute_type == :string || a.attribute_type == :s_enum
%>  nillable_attribute :<%= a.sql.column_name %>
  validates_length_of :<%= a.sql.column_name %>, :maximum => <%= a.length %>, :allow_nil => true
<%       end
         if a.reference?
%>  belongs_to :<%= underscore(a.name) %>, :class_name => '<%= a.referenced_object.ruby.fully_qualified_name %>', :foreign_key => '<%= a.sql.column_name %>'
  validates_reference_exists :<%= a.sql.column_name %>, <%= a.referenced_object.ruby.fully_qualified_name %>, :association_name => :<%= underscore(a.name) %>, :allow_nil => true
<%       end
       end
     end
   end %>
<% object_type.referencing_attributes.each do |attribute|
    if attribute.inverse_relationship_type == :has_many
%>
  has_many :<%= pluralize(underscore(attribute.inverse_relationship_name)) %>, :class_name => '<%= attribute.object_type.ruby.fully_qualified_name %>', :foreign_key => '<%= attribute.sql.column_name %>', :dependent => :destroy
  has_count_of :<%= pluralize(underscore(attribute.inverse_relationship_name)) %>
<%
    end
    if attribute.inverse_relationship_type == :has_one
%>
  has_one :<%= underscore(attribute.inverse_relationship_name) %>, :class_name => '<%= attribute.object_type.ruby.fully_qualified_name %>', :foreign_key => '<%= attribute.sql.column_name %>'
<%
    end
  end
%>

  # Make it possible for the users to extend the model by defining an extension class
  include <%= object_type.ruby.fully_qualified_name %>Extension rescue NameError
end

end
{'fraction_non_alphanumeric': 0.1824953445065177, 'fraction_numerical': 0.0, 'mean_word_length': 4.019541206457094, 'pattern_counts': {'":': 0, '<': 101, '<?xml version=': 0, '>': 129, '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': '2880150', 'n_tokens_mistral': 2222, 'n_tokens_neox': 2022, 'n_words': 327}