Module Gibbler::History
In: lib/gibbler/aliases.rb
lib/gibbler/history.rb

Methods

Public Class methods

Public Instance methods

Stores a clone of the current object instance using the current digest value. If the object was not changed, this method does nothing but return the gibble.

NOTE: This method is not fully thread safe. It uses a Mutex.synchronize but there‘s a race condition where two threads can attempt to commit at near the same time. The first will get the lock and create the commit. The second will get the lock and create another commit immediately after. What we probably want is for the second thread to return the digest for that first snapshot, but how do we know this was a result of the race conditioon rather than two legitimate calls for a snapshot?

Returns the long digest associated to the short digest g. If g is longer than 8 characters it returns the value of g.

Returns an Array of digests in the order they were committed. If short is anything but false, the digests will be converted to the short 8 character digests.

Does the current object have any history?

Returns the object stored under the given digest g. If g is not a valid digest, returns nil.

Revert this object to a previously known state. If called without arguments it will revert to the most recent commit. If a digest is specified g, it will revert to that point.

Ruby does not support replacing self (self = previous_self) so each object type needs to implement its own __gibbler_revert! method. This default run some common checks and then defers to self.__gibbler_revert!.

Raise the following exceptions:

If g matches the current digest value this method does nothing.

Returns the new digest (g).

Returns the timestamp (a Time object) when the digest g was committed. If g is not a valid gibble, returns nil.

Is the given digest g contained in the history for this object?

[Validate]