Module: Lockless::Relation

Defined in:
lib/lockless/relation.rb

Instance Method Summary collapse

Instance Method Details

#update_all(updates) ⇒ Boolean

Appends update attributes with a random UUID when the model is a lockless model

Lockless will only append random UUID updates if the param is a Hash

false is returned if record is outdated or invalid

Parameters:

  • A (String, Array, Hash)

    string, array, or hash representing the SET part of an SQL statement.

Returns:

  • (Boolean)

    Similar to ‘.save`, true is returned if the model is updated



12
13
14
15
16
17
18
19
20
# File 'lib/lockless/relation.rb', line 12

def update_all(updates)
  if updates.is_a?(Hash)
    if model.method_defined?(:lockless_column) && updates[model.lockless_column].blank?
      updates[model.lockless_column] = model.generate_uuid
    end
  end

  super(updates)
end