64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/couchbase-orm/associations.rb', line 64
def destroy_associations!
assoc = self.class.associations
assoc.each do |name, dependent|
next unless dependent
model = self.__send__(name)
if model.present?
case dependent
when :destroy, :delete
if model.respond_to?(:stream)
model.stream { |mod| mod.__send__(dependent) }
else
model.__send__(dependent)
end
when :restrict_with_exception
raise RecordExists.new("#{self.class.name} instance maintains a restricted reference to #{name}", self)
when :restrict_with_error
end
end
end
end
|