Sometimes data is referenced in code, for example a dynamically created "tab" has a key (it's unique id).
If we want to fetch that tab in our code, we do Tab.find_by_key('organisations')
. This will break if a user deletes this tab.
Locking some fields of an entity should solve this.
EntityLock
(entity_class, entity_uuid, attributes, reason)
EntityLock.lock(entity)
EntityLock.lock(entity, [key, name])
EntityLock.locked?(entity)
EntityLock.locked?(entity, for: attributes)
# attributes can be an array or hash (keys will be taken).
The entity would not know about locking and it would be up to a repository or service object to check.