abstract class Lockable

Overview

Lockable is an abstract class that provides a function #transaction! that allows the class to execute some code that requires to do not conflict with other operations. It is usually linked with an IO (a file).

Direct Known Subclasses

Defined in:

lib/lockable.cr

Instance Method Summary

Instance Method Detail

abstract def load! #

[View source]
abstract def save! #

[View source]
def transaction!(read = false, &) #

Execute some operation on the object, and then save it. The content can be loaded before executing the operations optionnaly.

someLockableObject.transaction(read: true) { |obj| obj.update_operation(...) }

[View source]