Method: Valkyrie::Persistence::Postgres::ResourceConverter#process_lock_token

Defined in:
lib/valkyrie/persistence/postgres/resource_converter.rb

#process_lock_token(orm_object) ⇒ Object

Retrieves the optimistic lock token from the Valkyrie attribute value and

sets it to the lock_version on ORM resource


31
32
33
34
35
36
37
38
# File 'lib/valkyrie/persistence/postgres/resource_converter.rb', line 31

def process_lock_token(orm_object)
  return unless resource.respond_to?(Valkyrie::Persistence::Attributes::OPTIMISTIC_LOCK)
  postgres_token = resource[Valkyrie::Persistence::Attributes::OPTIMISTIC_LOCK].find do |token|
    token.adapter_id == resource_factory.adapter_id
  end
  return unless postgres_token
  orm_object.lock_version = postgres_token.token
end