diff --git a/CHANGELOG.md b/CHANGELOG.md index 23500f2..74d5412 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.3.6 - 2024-08-07 +* Esse::LazyDocumentHeader#to_doc return `Esse::LazyDocumentHeader::Document` instance to properly separate context metadata from document source +* Add `.collection_class` method to the `Esse::Repository` class to let external plugins and extensions to access it instead of read @collection_proc variable + ## 0.3.5 - 2024-08-02 * Add `update_by_query` action to transport and index APIs * Reset index using `_reindex` api instead of the traditional collection `import` method diff --git a/Gemfile.lock b/Gemfile.lock index 6fd2d2b..33928ee 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - esse (0.3.5) + esse (0.3.6) multi_json thor (>= 0.19) diff --git a/gemfiles/Gemfile.elasticsearch-1.x.lock b/gemfiles/Gemfile.elasticsearch-1.x.lock index e44d348..382ab40 100644 --- a/gemfiles/Gemfile.elasticsearch-1.x.lock +++ b/gemfiles/Gemfile.elasticsearch-1.x.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - esse (0.3.5) + esse (0.3.6) multi_json thor (>= 0.19) diff --git a/gemfiles/Gemfile.elasticsearch-2.x.lock b/gemfiles/Gemfile.elasticsearch-2.x.lock index 8d56ee4..6cdb044 100644 --- a/gemfiles/Gemfile.elasticsearch-2.x.lock +++ b/gemfiles/Gemfile.elasticsearch-2.x.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - esse (0.3.5) + esse (0.3.6) multi_json thor (>= 0.19) diff --git a/gemfiles/Gemfile.elasticsearch-5.x.lock b/gemfiles/Gemfile.elasticsearch-5.x.lock index 109e235..14d0495 100644 --- a/gemfiles/Gemfile.elasticsearch-5.x.lock +++ b/gemfiles/Gemfile.elasticsearch-5.x.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - esse (0.3.5) + esse (0.3.6) multi_json thor (>= 0.19) diff --git a/gemfiles/Gemfile.elasticsearch-6.x.lock b/gemfiles/Gemfile.elasticsearch-6.x.lock index a93c58e..c4cd2c3 100644 --- a/gemfiles/Gemfile.elasticsearch-6.x.lock +++ b/gemfiles/Gemfile.elasticsearch-6.x.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - esse (0.3.5) + esse (0.3.6) multi_json thor (>= 0.19) diff --git a/gemfiles/Gemfile.elasticsearch-7.x.lock b/gemfiles/Gemfile.elasticsearch-7.x.lock index d12e7c3..388bc9e 100644 --- a/gemfiles/Gemfile.elasticsearch-7.x.lock +++ b/gemfiles/Gemfile.elasticsearch-7.x.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - esse (0.3.5) + esse (0.3.6) multi_json thor (>= 0.19) diff --git a/gemfiles/Gemfile.elasticsearch-8.x.lock b/gemfiles/Gemfile.elasticsearch-8.x.lock index 7e86b9d..31e84f7 100644 --- a/gemfiles/Gemfile.elasticsearch-8.x.lock +++ b/gemfiles/Gemfile.elasticsearch-8.x.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - esse (0.3.5) + esse (0.3.6) multi_json thor (>= 0.19) diff --git a/gemfiles/Gemfile.opensearch-1.x.lock b/gemfiles/Gemfile.opensearch-1.x.lock index 8f40c7f..ef7e822 100644 --- a/gemfiles/Gemfile.opensearch-1.x.lock +++ b/gemfiles/Gemfile.opensearch-1.x.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - esse (0.3.5) + esse (0.3.6) multi_json thor (>= 0.19) diff --git a/gemfiles/Gemfile.opensearch-2.x.lock b/gemfiles/Gemfile.opensearch-2.x.lock index 13328b3..913c057 100644 --- a/gemfiles/Gemfile.opensearch-2.x.lock +++ b/gemfiles/Gemfile.opensearch-2.x.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - esse (0.3.5) + esse (0.3.6) multi_json thor (>= 0.19) diff --git a/lib/esse/repository/object_document_mapper.rb b/lib/esse/repository/object_document_mapper.rb index d186786..d4f5d95 100644 --- a/lib/esse/repository/object_document_mapper.rb +++ b/lib/esse/repository/object_document_mapper.rb @@ -69,6 +69,15 @@ def collection(collection_klass = nil, **_, &block) @collection_proc = collection_klass || block end + # Expose the collection class to let external plugins and extensions to access it. + # @return [Class, nil] The collection class + # IDEA: When collection is defined as a block, it should setup a class with the block content. + def collection_class + return unless @collection_proc.is_a?(Class) + + @collection_proc + end + # Wrap collection data into serialized batches # # @param [Hash] kwargs The context diff --git a/lib/esse/version.rb b/lib/esse/version.rb index 7711f04..b80db78 100644 --- a/lib/esse/version.rb +++ b/lib/esse/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Esse - VERSION = '0.3.5' + VERSION = '0.3.6' end diff --git a/spec/esse/repository/collection_spec.rb b/spec/esse/repository/collection_spec.rb index 903cdfd..971f322 100644 --- a/spec/esse/repository/collection_spec.rb +++ b/spec/esse/repository/collection_spec.rb @@ -24,6 +24,7 @@ end end end + expect(klass.repo(:foo).collection_class).to be(nil) proc = klass.instance_variable_get(:@collection_proc) expect { |b| proc.call(&b).to yield_with_args([]) } @@ -45,6 +46,7 @@ collection DummyGeosCollection end end + expect(klass.repo(:foo).collection_class).to be(DummyGeosCollection) col_proc = klass.repo(:foo).instance_variable_get(:@collection_proc) expect(col_proc).to eq(DummyGeosCollection)