Module: Zvec
- Defined in:
- lib/zvec.rb,
lib/zvec/doc.rb,
lib/zvec/version.rb,
lib/zvec/collection.rb
Defined Under Namespace
Modules: CollectionConvenience Classes: Doc
Constant Summary collapse
- VERSION =
"0.1.0"
Class Method Summary collapse
-
.open_collection(path, options: nil) ⇒ Object
Block-form open: yields the collection and flushes on block exit.
-
.patch_shared_ptr_wrapper! ⇒ Object
Rice wraps shared_ptr
as Std::SharedPtrzvec::Collection, a proxy class that delegates C++ methods via method_missing.
Class Method Details
.open_collection(path, options: nil) ⇒ Object
Block-form open: yields the collection and flushes on block exit
25 26 27 28 29 30 |
# File 'lib/zvec/collection.rb', line 25 def self.open_collection(path, options: nil) col = Collection.open(path, ) yield col ensure col&.flush end |
.patch_shared_ptr_wrapper! ⇒ Object
Rice wraps shared_ptr
14 15 16 17 18 19 20 21 22 |
# File 'lib/zvec.rb', line 14 def self.patch_shared_ptr_wrapper! ObjectSpace.each_object(Class) do |klass| if klass.name&.start_with?("Std::SharedPtr") && klass.name&.include?("Collection") klass.include(Zvec::CollectionConvenience) return klass end end nil end |