2020-10-24 23:57:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module ResourceEvents
|
|
|
|
class BaseChangeTimeboxService
|
2021-03-11 19:13:27 +05:30
|
|
|
attr_reader :resource, :user
|
2020-10-24 23:57:45 +05:30
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
def initialize(resource, user)
|
2020-10-24 23:57:45 +05:30
|
|
|
@resource = resource
|
|
|
|
@user = user
|
|
|
|
end
|
|
|
|
|
|
|
|
def execute
|
|
|
|
create_event
|
|
|
|
|
|
|
|
resource.expire_note_etag_cache
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def create_event
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
|
|
|
def build_resource_args
|
|
|
|
key = resource.class.name.foreign_key
|
|
|
|
|
|
|
|
{
|
|
|
|
user_id: user.id,
|
2021-03-11 19:13:27 +05:30
|
|
|
created_at: resource.system_note_timestamp,
|
2020-10-24 23:57:45 +05:30
|
|
|
key => resource.id
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|