Class: Cybertrain::DB::Blob
- Inherits:
-
Object
- Object
- Cybertrain::DB::Blob
- Defined in:
- cybertrain/db/blob.rb
Overview
A bind value that goes to SQLite as a BLOB: Connection#bind sends
its bytes with sqlite3_bind_blob and their byte length, so a NUL byte
or a byte above 127 is stored as it is. Every other String binds as
TEXT, which is why a binary column’s value is wrapped in one (the
generated models’ to_row does it for t.binary columns).
Reading needs no wrapper: a BLOB cell comes back from
Connection#execute as a String holding exactly the stored bytes
(Cast.binary narrows such a cell to a String, “” for NULL).
Instance Attribute Summary collapse
-
#blob_bytes ⇒ String
readonly
The bytes to store.
Instance Method Summary collapse
-
#initialize(bytes) ⇒ Blob
constructor
A new instance of Blob.
Constructor Details
#initialize(bytes) ⇒ Blob
Returns a new instance of Blob.
27 28 29 |
# File 'cybertrain/db/blob.rb', line 27 def initialize(bytes) @blob_bytes = bytes end |
Instance Attribute Details
#blob_bytes ⇒ String (readonly)
The bytes to store. A distinctive name, not bytes or data
(spikes/NOTES.md rules 10 and 34).
23 24 25 |
# File 'cybertrain/db/blob.rb', line 23 def blob_bytes @blob_bytes end |