Module: Tenacity::Associations::BelongsTo

Included in:
Tenacity
Defined in:
lib/tenacity/associations/belongs_to.rb

Overview

:nodoc:

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#_t_cleanup_belongs_to_association(association) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/tenacity/associations/belongs_to.rb', line 5

def _t_cleanup_belongs_to_association(association)
  associate_id = self.send(association.foreign_key)
  if associate_id != nil && associate_id.to_s.strip != ''
    if association.dependent == :destroy
      delete_or_destroy_belongs_to_associate(association, associate_id)
    elsif association.dependent == :delete
      delete_or_destroy_belongs_to_associate(association, associate_id, false)
    end
  end
end