Module: Babik::QuerySet::Lockable

Included in:
AbstractBase
Defined in:
lib/babik/queryset/mixins/lockable.rb

Overview

Lock functionality of QuerySet

Instance Method Summary collapse

Instance Method Details

#for_update!Object

Lock the table for writes This must be inside a transaction



10
11
12
13
# File 'lib/babik/queryset/mixins/lockable.rb', line 10

def for_update!
  @_lock_type = 'FOR UPDATE'
  self
end

#lock!Object

Lock the table for writes This must be inside a transaction

See Also:

  • Alias of for_update method


18
19
20
# File 'lib/babik/queryset/mixins/lockable.rb', line 18

def lock!
  self.for_update!
end

#lock?Boolean

Check if there is a lock

Returns:

  • (Boolean)

    True if there is a lock, false otherwise.



24
25
26
27
# File 'lib/babik/queryset/mixins/lockable.rb', line 24

def lock?
  return true if @_lock_type
  false
end