Module: Tenacity::InstanceMethods

Included in:
Tenacity
Defined in:
lib/tenacity/instance_methods.rb

Overview

:nodoc:

Instance Method Summary (collapse)

Instance Method Details

- (Object) _t_ivar_name(association)



4
5
6
# File 'lib/tenacity/instance_methods.rb', line 4

def _t_ivar_name(association)
  "@_t_" + association.name.to_s
end

- (Object) _t_save_autosave_associations



8
9
10
11
12
13
14
15
16
# File 'lib/tenacity/instance_methods.rb', line 8

def _t_save_autosave_associations
  autosave_associations.each do |association|
    if association.type == :t_has_one || association.type == :t_belongs_to
      autosave_has_one_or_belongs_to(association)
    elsif association.type == :t_has_many
      autosave_has_many(association)
    end
  end
end

- (Object) _t_verify_associates_exist



18
19
20
21
22
23
24
25
26
27
# File 'lib/tenacity/instance_methods.rb', line 18

def _t_verify_associates_exist
  associations_requiring_associate_validation.each do |association|
    associate_id = self.send(association.foreign_key)
    unless associate_id.nil?
      associate_class = association.associate_class(self)
      associate = associate_class._t_find(_t_serialize(associate_id, association))
      raise ObjectDoesNotExistError.new("#{associate_class} object with an id of #{associate_id} does not exist!") if associate.nil?
    end
  end
end