Skip to content

Commit

Permalink
Adjust UpdateLazyAttribute callback to not use keyword arguments for …
Browse files Browse the repository at this point in the history
…better compatibility with older versions of Ruby
  • Loading branch information
marcosgz committed Aug 8, 2024
1 parent b3c0d3e commit 820af84
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 11 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ 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.8 - 2024-?
## 0.3.8 - 2024-08-08
* Add `connect_with:` option to the collection definition.
* Adjust UpdateLazyAttribute callback to not use keyword arguments for better compatibility with older versions of Ruby.

## 0.3.7 - 2024-08-05
* Add `connected_to` to the collection for custom connection handling
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-active_record (0.3.7)
esse-active_record (0.3.8)
activerecord (>= 4.2, < 8)
esse (>= 0.3.0)

Expand Down
2 changes: 1 addition & 1 deletion ci/Gemfile.rails-5.2.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ..
specs:
esse-active_record (0.3.7)
esse-active_record (0.3.8)
activerecord (>= 4.2, < 8)
esse (>= 0.3.0)

Expand Down
2 changes: 1 addition & 1 deletion ci/Gemfile.rails-6.0.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ..
specs:
esse-active_record (0.3.7)
esse-active_record (0.3.8)
activerecord (>= 4.2, < 8)
esse (>= 0.3.0)

Expand Down
2 changes: 1 addition & 1 deletion ci/Gemfile.rails-6.1.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ..
specs:
esse-active_record (0.3.7)
esse-active_record (0.3.8)
activerecord (>= 4.2, < 8)
esse (>= 0.3.0)

Expand Down
2 changes: 1 addition & 1 deletion ci/Gemfile.rails-7.0.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ..
specs:
esse-active_record (0.3.7)
esse-active_record (0.3.8)
activerecord (>= 4.2, < 8)
esse (>= 0.3.0)

Expand Down
2 changes: 1 addition & 1 deletion ci/Gemfile.rails-7.1.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ..
specs:
esse-active_record (0.3.7)
esse-active_record (0.3.8)
activerecord (>= 4.2, < 8)
esse (>= 0.3.0)

Expand Down
4 changes: 2 additions & 2 deletions lib/esse/active_record/callbacks/update_lazy_attribute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ def initialize(attribute_name:, **kwargs, &block)
end

def call(model)
related_ids = Array(block_result || model.id)
related_ids = Esse::ArrayUtils.wrap(block_result || model.id)
return true if related_ids.empty?

repo.update_documents_attribute(attribute_name, *related_ids, **options)
repo.update_documents_attribute(attribute_name, related_ids, options)

true
end
Expand Down
2 changes: 1 addition & 1 deletion lib/esse/active_record/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module Esse
module ActiveRecord
VERSION = '0.3.7'
VERSION = '0.3.8'
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
it 'bulk update the state :total_counties attribute when the county is created' do
state = create_record(State, name: 'Illinois')
county = build_record(county_class, name: 'Cook', state: state)
expect(StatesIndex::State).to receive(:update_documents_attribute).with(:total_counties, state.id, **{}).and_call_original
expect(StatesIndex::State).to receive(:update_documents_attribute).with(:total_counties, [state.id], {}).and_call_original
expect(StatesIndex).to esse_receive_request(:bulk).with(
index: StatesIndex.index_name,
body: [
Expand Down

0 comments on commit 820af84

Please sign in to comment.