Class: Textus::Store::Envelope::Reader
- Inherits:
-
Object
- Object
- Textus::Store::Envelope::Reader
- Defined in:
- lib/textus/store/envelope/reader.rb
Overview
Read-only counterpart to EnvelopeWriter. Resolves a key, reads the bytes, parses them via the format strategy, and hands back an Envelope. Used by Mv (pre-move inspection) and by EnvelopeWriter (existing-meta lookup for the uid/sources preservation step in #put).
No audit, no events, no permission checks — those live one layer up.
Class Method Summary collapse
Instance Method Summary collapse
- #exists?(key) ⇒ Boolean
-
#initialize(file_store:, manifest:, geometry:) ⇒ Reader
constructor
A new instance of Reader.
- #read(key) ⇒ Object
Constructor Details
#initialize(file_store:, manifest:, geometry:) ⇒ Reader
Returns a new instance of Reader.
16 17 18 19 20 |
# File 'lib/textus/store/envelope/reader.rb', line 16 def initialize(file_store:, manifest:, geometry:) @file_store = file_store @manifest = manifest @geometry = geometry end |
Class Method Details
.from(container:) ⇒ Object
11 12 13 14 |
# File 'lib/textus/store/envelope/reader.rb', line 11 def self.from(container:) new(file_store: container.file_store, manifest: container.manifest, geometry: container.geometry) end |
Instance Method Details
#exists?(key) ⇒ Boolean
37 38 39 |
# File 'lib/textus/store/envelope/reader.rb', line 37 def exists?(key) @file_store.exists?(@manifest.resolver.resolve(key).path) end |
#read(key) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/textus/store/envelope/reader.rb', line 22 def read(key) res = @manifest.resolver.resolve(key) path = res.path return nil unless @file_store.exists?(path) mentry = res.entry raw = @file_store.read(path) parsed = Format.for(mentry.format).parse(raw, path: path) Textus::Value::Envelope.build( key: key, mentry: mentry, path: path, meta: parsed["_meta"], body: parsed["body"], etag: Value::Etag.for_bytes(raw), content: parsed["content"] ) end |