Class: Sandals::SnapshotHistory
- Inherits:
-
Object
- Object
- Sandals::SnapshotHistory
- Defined in:
- lib/sandals/snapshot_history.rb
Defined Under Namespace
Classes: Snapshot
Instance Method Summary collapse
- #current ⇒ Object
- #discard_before(revision) ⇒ Object
- #fetch(revision) ⇒ Object
-
#initialize ⇒ SnapshotHistory
constructor
A new instance of SnapshotHistory.
- #publish(view, controls:) ⇒ Object
Constructor Details
#initialize ⇒ SnapshotHistory
Returns a new instance of SnapshotHistory.
7 8 9 10 |
# File 'lib/sandals/snapshot_history.rb', line 7 def initialize @revision = 0 @snapshots = [] end |
Instance Method Details
#current ⇒ Object
26 27 28 |
# File 'lib/sandals/snapshot_history.rb', line 26 def current @snapshots.last end |
#discard_before(revision) ⇒ Object
30 31 32 |
# File 'lib/sandals/snapshot_history.rb', line 30 def discard_before(revision) @snapshots.reject! { |snapshot| snapshot.revision < revision } end |
#fetch(revision) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/sandals/snapshot_history.rb', line 19 def fetch(revision) snapshot = @snapshots.find { |candidate| candidate.revision == revision } return snapshot if snapshot raise ArgumentError, "unknown revision: #{revision}" end |