Class: Whodunit::Chronicles::Ledger
- Inherits:
-
Object
- Object
- Whodunit::Chronicles::Ledger
- Defined in:
- lib/whodunit/chronicles/ledger.rb,
sig/whodunit/chronicles/ledger.rbs
Overview
Base class for append-only audit ledgers.
Ledger is the minimal storage contract consumed by Chronicler. Concrete ledgers only need to implement #append; preparation, indexing, and partitioning are optional capabilities with safe defaults.
Direct Known Subclasses
Whodunit::Chronicles::Ledgers::FileLedger, Whodunit::Chronicles::Ledgers::MemoryLedger, Whodunit::Chronicles::Ledgers::SQLiteLedger
Instance Method Summary collapse
-
#append(_entry) ⇒ Object
Append an immutable entry to the ledger.
-
#ensure_indexes! ⇒ Ledger
Ensure useful indexes if the ledger supports index management.
-
#migrate! ⇒ Ledger
Apply storage evolution steps if the ledger supports migrations.
-
#partition_for(_entry) ⇒ Ledger
Return the target ledger for an entry.
-
#prepare! ⇒ Ledger
Prepare backing storage if the ledger supports schema creation.
-
#status ⇒ Hash<Symbol, Object>
Return lightweight operational status for this ledger.
-
#verify ⇒ Boolean
Verify that the ledger is operational.
Instance Method Details
#append(_entry) ⇒ Object
Append an immutable entry to the ledger.
64 65 66 |
# File 'lib/whodunit/chronicles/ledger.rb', line 64 def append(_entry) raise NotImplementedError, "#{self.class} must implement #append" end |
#ensure_indexes! ⇒ Ledger
Ensure useful indexes if the ledger supports index management.
21 22 23 |
# File 'lib/whodunit/chronicles/ledger.rb', line 21 def ensure_indexes! self end |
#migrate! ⇒ Ledger
Apply storage evolution steps if the ledger supports migrations.
28 29 30 31 32 |
# File 'lib/whodunit/chronicles/ledger.rb', line 28 def migrate! prepare! ensure_indexes! self end |
#partition_for(_entry) ⇒ Ledger
Return the target ledger for an entry.
Partition-aware ledgers override this method. Simple ledgers return themselves.
55 56 57 |
# File 'lib/whodunit/chronicles/ledger.rb', line 55 def partition_for(_entry) self end |
#prepare! ⇒ Ledger
Prepare backing storage if the ledger supports schema creation.
14 15 16 |
# File 'lib/whodunit/chronicles/ledger.rb', line 14 def prepare! self end |
#status ⇒ Hash<Symbol, Object>
Return lightweight operational status for this ledger.
44 45 46 |
# File 'lib/whodunit/chronicles/ledger.rb', line 44 def status { adapter: self.class.name, ready: verify } end |
#verify ⇒ Boolean
Verify that the ledger is operational.
37 38 39 |
# File 'lib/whodunit/chronicles/ledger.rb', line 37 def verify true end |