Module: Tengine::Core::OptimisticLock::ClassMethods
- Defined in:
- lib/tengine/core/optimistic_lock.rb
Overview
ActiveRecord::Locking::Optimistic::ClassMethods を参考に実装していますgithub.com/rails/rails/blob/master/activerecord/lib/active_record/locking/optimistic.rb
Constant Summary collapse
- DEFAULT_LOCKING_FIELD =
'lock_version'.freeze
Instance Method Summary collapse
-
#locking_field ⇒ Object
The version field used for optimistic locking.
-
#reset_locking_field ⇒ Object
Reset the field used for optimistic locking back to the
lock_versiondefault. -
#set_locking_field(value = nil) ⇒ Object
Set the field to use for optimistic locking.
Instance Method Details
#locking_field ⇒ Object
The version field used for optimistic locking. Defaults to lock_version.
82 83 84 |
# File 'lib/tengine/core/optimistic_lock.rb', line 82 def locking_field reset_locking_field end |
#reset_locking_field ⇒ Object
Reset the field used for optimistic locking back to the lock_version default.
87 88 89 |
# File 'lib/tengine/core/optimistic_lock.rb', line 87 def reset_locking_field set_locking_field DEFAULT_LOCKING_FIELD end |
#set_locking_field(value = nil) ⇒ Object
Set the field to use for optimistic locking. Defaults to lock_version.
75 76 77 78 79 |
# File 'lib/tengine/core/optimistic_lock.rb', line 75 def set_locking_field(value = nil) # 後者のlocking_fieldメソッドを上書きします。 self.instance_eval("def locking_field; #{value.inspect}; end") value end |