2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2017-05-05 09:16:47 +00:00
|
|
|
module HasLinks
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
included do
|
|
|
|
before_destroy :links_destroy
|
|
|
|
end
|
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
delete object link list, will be executed automatically
|
|
|
|
|
|
|
|
model = Model.find(123)
|
|
|
|
model.links_destroy
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def links_destroy
|
|
|
|
Link.remove_all(
|
2018-12-19 17:31:51 +00:00
|
|
|
link_object: self.class.to_s,
|
2017-05-05 09:16:47 +00:00
|
|
|
link_object_value: id,
|
|
|
|
)
|
2017-06-16 22:53:20 +00:00
|
|
|
true
|
2017-05-05 09:16:47 +00:00
|
|
|
end
|
|
|
|
end
|