trabajo-afectivo/app/models/application_model/can_touch_references.rb

30 lines
622 B
Ruby
Raw Permalink Normal View History

2022-01-01 13:38:12 +00:00
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
module ApplicationModel::CanTouchReferences
extend ActiveSupport::Concern
# methods defined here are going to extend the class, not the instance of it
class_methods do
=begin
touch references by params
Model.touch_reference_by_params(
object: 'Ticket',
o_id: 123,
)
=end
def touch_reference_by_params(data)
object = data[:object].constantize.lookup(id: data[:o_id])
return if !object
2017-11-23 08:09:44 +00:00
object.touch # rubocop:disable Rails/SkipsModelValidations
rescue => e
logger.error e
end
end
end