<commit_before># require 'email_user'
# require 'email_user_association'
# require 'action_controller'
# require 'application_helper'
# require 'action_controller/url_writer'
module ActiveMailer #:nodoc:
  class Base < ActiveRecord::Base
    self.abstract_class = true

    has_many    :email_user_associations, :as => :emailable
    has_many    :recipients, :through => :email_user_associations, :source => "email_user"
    belongs_to  :sender, :class_name => "ActiveMailer::EmailUser", :foreign_key => "sender_id"
    attr_accessor :body     # leave this as an accessor for now since it's complicated
    attr_accessor :rendered_contents # contains the actual sent email after `send!` is called

    validates_presence_of :sender
    validates_length_of   :subject,    :minimum => 1

    validate :must_have_at_least_one_recipient_of_some_kind

    def must_have_at_least_one_recipient_of_some_kind
      if self.recipients.blank? and self.cc.blank? and self.bcc.blank?
        self.errors[:base] << "You have to have at least one recipient in the to, cc, or bcc fields"
      end
    end

    cattr_accessor :before_send_actions
    cattr_accessor :after_send_actions

    class_attribute :mailer_variables

    alias :ar_sender= :sender=
    def sender=(email)
      if email.is_a?(String)
        self.ar_sender = EmailUser.find_or_create_by(:email_address => email)
      else<commit_msg>use symbol for source to see if that fixes the HasManyThroughSourceAssociationNotFoundError<commit_after># require 'email_user'
# require 'email_user_association'
# require 'action_controller'
# require 'application_helper'
# require 'action_controller/url_writer'
module ActiveMailer #:nodoc:
  class Base < ActiveRecord::Base
    self.abstract_class = true

    has_many    :email_user_associations, :as => :emailable
    has_many    :recipients, :through => :email_user_associations, :source => :email_user
    belongs_to  :sender, :class_name => "ActiveMailer::EmailUser", :foreign_key => "sender_id"
    attr_accessor :body     # leave this as an accessor for now since it's complicated
    attr_accessor :rendered_contents # contains the actual sent email after `send!` is called

    validates_presence_of :sender
    validates_length_of   :subject,    :minimum => 1

    validate :must_have_at_least_one_recipient_of_some_kind

    def must_have_at_least_one_recipient_of_some_kind
      if self.recipients.blank? and self.cc.blank? and self.bcc.blank?
        self.errors[:base] << "You have to have at least one recipient in the to, cc, or bcc fields"
      end
    end

    cattr_accessor :before_send_actions
    cattr_accessor :after_send_actions

    class_attribute :mailer_variables

    alias :ar_sender= :sender=
    def sender=(email)
      if email.is_a?(String)
        self.ar_sender = EmailUser.find_or_create_by(:email_address => email)
      else
{'fraction_non_alphanumeric': 0.0806282722513089, 'fraction_numerical': 0.0006980802792321117, 'mean_word_length': 4.278084714548803, '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': '1860324', 'n_tokens_mistral': 919, 'n_tokens_neox': 883, 'n_words': 227}