Module: ArtirixDataModels::Model::CacheKey

Extended by:
ActiveSupport::Concern
Defined in:
lib/artirix_data_models/model.rb

Constant Summary collapse

EMPTY_TIMESTAMP =
'no_time'.freeze
SEPARATOR =
'/'.freeze

Instance Method Summary collapse

Instance Method Details

#cache_keyObject



369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
# File 'lib/artirix_data_models/model.rb', line 369

def cache_key
  # we do not want to force a reload for loading the cache key, it can lead to an infinite loop
  # so if the model is in partial mode, we mark it as full mode, and back as partial later.
  temp_full_mode = false
  if try(:partial_mode?)
    temp_full_mode = true
    try(:mark_full_mode)
  end

  m = try(:model_dao_name) || self.class
  i = try(:primary_key) || try(:id) || try(:object_id)
  t = try(:_timestamp) || try(:updated_at) || EMPTY_TIMESTAMP

  if temp_full_mode
    try(:mark_partial_mode)
  end

  [
    m.to_s.parameterize,
    i.to_s.parameterize,
    t.to_s.parameterize,
  ].join SEPARATOR
end