active_hash 4.0.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dbf4b348b5da82f53662271a13a45c1994da941db9c825c68eaa30ad38a45ed1
4
- data.tar.gz: 9cad29ee714bd667b973423771c6a6df988c0c38665a6bd12583980bf41b57da
3
+ metadata.gz: 87c94fe12c3633dc4d691ff9c67c818ec68495f89e5529130b2e4d49504cefd3
4
+ data.tar.gz: dab8cc2c530de82a9020a68d128ca1d6c815aa68ab977ea242a3f2d8470d8c22
5
5
  SHA512:
6
- metadata.gz: 2487660659ae746870005b8c6cda566ace4aa7119afe15a4b441a5396708970c8d4e5a904592337fadad9acedfe10976434fdf70829633ed7f297edaffa7872d
7
- data.tar.gz: ecff618c93428de090964526091d43a6ebe17abb4b7822968c1812f326e3a7a08f06092fd0d658713eb2d7db909be5316897ef42adc8cf6f22f73dedf93b4999
6
+ metadata.gz: 1cb506c09e918622c2581d2f7727076db0fbc43a4940cd90dad2ff96857b16d19b2b77bb1b808e7c160ab4109ad7b97369b167a7c057730cd9806e6fbef72988
7
+ data.tar.gz: 8588f0311f2b680147bec5606cfdbc5ec0b0a224672c28dbd33c67bd88d85351050baf726eaaaa8c908c4c5d5e3200314f4939a29368244da81b5c8bcf9e88db
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # active_hash Changelog
2
2
 
3
+ ## Version [4.1.0] - <sub><sup>2026-04-01</sup></sub>
4
+
5
+ ### Added
6
+
7
+ - Add `Relation#or` support [#343](https://github.com/active-hash/active_hash/pull/343) @opsys-saito
8
+ - Alias `Relation#find_each` and `Base#find_each` to `#each` [#333](https://github.com/active-hash/active_hash/pull/333) @DmitryBarskov
9
+
10
+ ### Fixed
11
+
12
+ - Fix `exists?` to support ids which are strings [#339](https://github.com/active-hash/active_hash/pull/339) @mtmail
13
+ - Fix `model_name` availability when using `ActiveModel::Serialization` [#335](https://github.com/active-hash/active_hash/pull/335) @moznion
14
+
3
15
  ## Version [4.0.0] - <sub><sup>2025-07-30</sup></sub>
4
16
 
5
17
  ### Added
@@ -353,8 +365,8 @@
353
365
  - Setting data to nil correctly causes .all to return an empty array
354
366
  - Added reload(force) method, so that you can force a reload from files in ActiveFile, useful for tests
355
367
 
356
- [HEAD]: https://github.com/active-hash/active_hash/compare/v3.4.0...HEAD
357
- [3.3.2]: https://github.com/active-hash/active_hash/compare/v3.3.1...v3.4.0
368
+ [HEAD]: https://github.com/active-hash/active_hash/compare/v4.1.0...HEAD
369
+ [4.1.0]: https://github.com/active-hash/active_hash/compare/v4.0.0...v4.1.0
358
370
  [3.3.1]: https://github.com/active-hash/active_hash/compare/v3.3.0...v3.3.1
359
371
  [3.3.0]: https://github.com/active-hash/active_hash/compare/v3.2.1...v3.3.0
360
372
  [3.2.1]: https://github.com/active-hash/active_hash/compare/v3.2.0...v3.2.1
@@ -49,7 +49,7 @@ module ActiveFile
49
49
  end
50
50
  protected :actual_root_path
51
51
 
52
- [:find, :find_by_id, :all, :where, :method_missing].each do |method|
52
+ [:find, :find_by_id, :all, :where, :method_missing, :find_each].each do |method|
53
53
  define_method(method) do |*args, &block|
54
54
  reload unless data_loaded
55
55
  return super(*args, &block)
@@ -24,6 +24,7 @@ module ActiveHash
24
24
  class_attribute :_data, :dirty, :default_attributes, :scopes
25
25
 
26
26
  if Object.const_defined?(:ActiveModel)
27
+ extend ActiveModel::Naming
27
28
  extend ActiveModel::Translation
28
29
  include ActiveModel::Conversion
29
30
  else
@@ -112,7 +113,7 @@ module ActiveHash
112
113
  elsif args.is_a?(Hash)
113
114
  all.where(args).present?
114
115
  else
115
- all.where(id: args.to_i).present?
116
+ all.where(id: args.to_s).present?
116
117
  end
117
118
  end
118
119
 
@@ -189,7 +190,7 @@ module ActiveHash
189
190
  relation
190
191
  end
191
192
 
192
- delegate :where, :find, :find_by, :find_by!, :find_by_id, :count, :pluck, :ids, :pick, :first, :last, :order, to: :all
193
+ delegate :where, :find_each, :find, :find_by, :find_by!, :find_by_id, :count, :pluck, :ids, :pick, :first, :last, :order, to: :all
193
194
 
194
195
  def transaction
195
196
  yield
@@ -7,6 +7,8 @@ module ActiveHash
7
7
  delegate :empty?, :length, :first, :second, :third, :last, to: :records
8
8
  delegate :sample, to: :records
9
9
 
10
+ alias find_each each
11
+
10
12
  attr_reader :conditions, :order_values, :klass, :all_records
11
13
 
12
14
  def initialize(klass, all_records, conditions = nil, order_values = nil)
@@ -22,6 +24,22 @@ module ActiveHash
22
24
  spawn.where!(conditions_hash)
23
25
  end
24
26
 
27
+ def or(other)
28
+ unless other.is_a?(self.class)
29
+ raise ArgumentError, "or() expects an ActiveHash::Relation"
30
+ end
31
+
32
+ unless other.klass == klass
33
+ raise ArgumentError, "or() expects relations for the same model"
34
+ end
35
+
36
+ merged = (records + other.records).uniq do |record|
37
+ record.respond_to?(:id) ? record.id : record.object_id
38
+ end
39
+
40
+ self.class.new(klass, merged, [], order_values)
41
+ end
42
+
25
43
  def pretty_print(pp)
26
44
  pp.pp(entries.to_ary)
27
45
  end
@@ -1,5 +1,5 @@
1
1
  module ActiveHash
2
2
  module Gem
3
- VERSION = "4.0.0"
3
+ VERSION = "4.1.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_hash
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Dean
@@ -26,10 +26,9 @@ authors:
26
26
  - Brett Richardson
27
27
  - Rachel Heaton
28
28
  - Keisuke Izumiya
29
- autorequire:
30
29
  bindir: bin
31
30
  cert_chain: []
32
- date: 2025-07-29 00:00:00.000000000 Z
31
+ date: 1980-01-02 00:00:00.000000000 Z
33
32
  dependencies:
34
33
  - !ruby/object:Gem::Dependency
35
34
  name: activesupport
@@ -93,7 +92,6 @@ metadata:
93
92
  changelog_uri: https://github.com/active-hash/active_hash/blob/master/CHANGELOG.md
94
93
  source_code_uri: http://github.com/active-hash/active_hash
95
94
  bug_tracker_uri: https://github.com/active-hash/active_hash/issues
96
- post_install_message:
97
95
  rdoc_options: []
98
96
  require_paths:
99
97
  - lib
@@ -108,8 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
106
  - !ruby/object:Gem::Version
109
107
  version: '0'
110
108
  requirements: []
111
- rubygems_version: 3.5.22
112
- signing_key:
109
+ rubygems_version: 4.0.9
113
110
  specification_version: 4
114
111
  summary: An ActiveRecord-like model that uses a hash or file as a datasource
115
112
  test_files: []