Skip to content

Commit

Permalink
feat: add collection_class method to repository
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosgz committed Aug 7, 2024
1 parent 600c0e8 commit 322d9d7
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
esse (0.3.5)
esse (0.3.6)
multi_json
thor (>= 0.19)

Expand Down
2 changes: 1 addition & 1 deletion gemfiles/Gemfile.elasticsearch-1.x.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ..
specs:
esse (0.3.5)
esse (0.3.6)
multi_json
thor (>= 0.19)

Expand Down
2 changes: 1 addition & 1 deletion gemfiles/Gemfile.elasticsearch-2.x.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ..
specs:
esse (0.3.5)
esse (0.3.6)
multi_json
thor (>= 0.19)

Expand Down
2 changes: 1 addition & 1 deletion gemfiles/Gemfile.elasticsearch-5.x.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ..
specs:
esse (0.3.5)
esse (0.3.6)
multi_json
thor (>= 0.19)

Expand Down
2 changes: 1 addition & 1 deletion gemfiles/Gemfile.elasticsearch-6.x.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ..
specs:
esse (0.3.5)
esse (0.3.6)
multi_json
thor (>= 0.19)

Expand Down
2 changes: 1 addition & 1 deletion gemfiles/Gemfile.elasticsearch-7.x.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ..
specs:
esse (0.3.5)
esse (0.3.6)
multi_json
thor (>= 0.19)

Expand Down
2 changes: 1 addition & 1 deletion gemfiles/Gemfile.elasticsearch-8.x.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ..
specs:
esse (0.3.5)
esse (0.3.6)
multi_json
thor (>= 0.19)

Expand Down
2 changes: 1 addition & 1 deletion gemfiles/Gemfile.opensearch-1.x.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ..
specs:
esse (0.3.5)
esse (0.3.6)
multi_json
thor (>= 0.19)

Expand Down
2 changes: 1 addition & 1 deletion gemfiles/Gemfile.opensearch-2.x.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ..
specs:
esse (0.3.5)
esse (0.3.6)
multi_json
thor (>= 0.19)

Expand Down
9 changes: 9 additions & 0 deletions lib/esse/repository/object_document_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/esse/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Esse
VERSION = '0.3.5'
VERSION = '0.3.6'
end
2 changes: 2 additions & 0 deletions spec/esse/repository/collection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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([]) }
Expand All @@ -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)
Expand Down

0 comments on commit 322d9d7

Please sign in to comment.