active_record_compose 1.2.1 → 1.4.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 +4 -4
- data/CHANGELOG.md +22 -0
- data/README.md +4 -0
- data/lib/active_record_compose/attributes.rb +5 -3
- data/lib/active_record_compose/composed_collection.rb +2 -1
- data/lib/active_record_compose/exceptions.rb +15 -2
- data/lib/active_record_compose/model.rb +1 -1
- data/lib/active_record_compose/transaction_support/active_transaction.rb +42 -0
- data/lib/active_record_compose/transaction_support/transaction_coordinator.rb +47 -0
- data/lib/active_record_compose/transaction_support.rb +60 -27
- data/lib/active_record_compose/version.rb +12 -1
- data/lib/active_record_compose.rb +4 -0
- data/sig/_internal/package_private.rbs +22 -0
- data/sig/active_record_compose.rbs +11 -2
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 91c3305d64d7b4e8b0cf57e127b9b1e48c0a413a5749d79f1afef5d659814271
|
|
4
|
+
data.tar.gz: 321aa91ad6500b97a38f02ea70f5904c2852016eddf7fb4388186e25c83ff825
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ad550be47844182ac031aaa4c9df4c344e0b14a3173a3402c2e7d44123bd953c1b2ef4f62e0ff5ca8d49c17f688cb9a6c5385d1aeb810bb34263d7f2203cd943
|
|
7
|
+
data.tar.gz: a97affe0e201a77cb207ba0d013194c9b1a30a79611a80d4d0e133904bfd8f016e2f330a126428acdec22f248bfa2ed999df62db46a5174fe8deb3ec2ebaee84
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [1.4.0] - 2026-10-14
|
|
4
|
+
|
|
5
|
+
* Use a dedicated deprecator for deprecated APIs.
|
|
6
|
+
(https://github.com/hamajyotan/active_record_compose/pull/75)
|
|
7
|
+
* Fix `before_commit` callback timing for transactions spanning multiple database connections.
|
|
8
|
+
(https://github.com/hamajyotan/active_record_compose/pull/76)
|
|
9
|
+
- Ensure that `before_commit` callbacks are invoked at the appropriate point before the outermost transaction commits.
|
|
10
|
+
- Leave behavior unchanged when all models use a single database connection.
|
|
11
|
+
* Perform validations outside a transaction.
|
|
12
|
+
(https://github.com/hamajyotan/active_record_compose/pull/78)
|
|
13
|
+
* Execute inner models' `after_commit` callbacks before outer models' callbacks.
|
|
14
|
+
(https://github.com/hamajyotan/active_record_compose/pull/79)
|
|
15
|
+
* Add `ActiveRecordCompose::UninitializedAttribute#record`.
|
|
16
|
+
|
|
17
|
+
## [1.3.0] - 2026-08-09
|
|
18
|
+
|
|
19
|
+
* Support secondary and multiple database
|
|
20
|
+
(https://github.com/hamajyotan/active_record_compose/pull/74)
|
|
21
|
+
- When models connecting to different databases are used together, the system behaves in a manner simulating a two-phase commit.
|
|
22
|
+
- Due to the nature of the ActiveRecord API supported by Rails, a true two-phase commit is not implemented; instead, transactions are nested when multiple database connections are involved.
|
|
23
|
+
- Note that operations remain unchanged when all models belong to a single primary database.
|
|
24
|
+
|
|
3
25
|
## [1.2.1] - 2026-03-21
|
|
4
26
|
|
|
5
27
|
* Improved clarity of error when accessing uninitialized attributes.
|
data/README.md
CHANGED
|
@@ -59,6 +59,10 @@ $ bundle
|
|
|
59
59
|
|
|
60
60
|
## Quick Start
|
|
61
61
|
|
|
62
|
+
For a complete runnable application, see the Sample Application section below.
|
|
63
|
+
|
|
64
|
+
The examples in this section focus on ActiveRecordCompose itself and intentionally omit surrounding application code such as migrations, routes, views, and jobs.
|
|
65
|
+
|
|
62
66
|
### Basic Example
|
|
63
67
|
|
|
64
68
|
Suppose you have two models:
|
|
@@ -167,14 +167,16 @@ module ActiveRecordCompose
|
|
|
167
167
|
|
|
168
168
|
private
|
|
169
169
|
|
|
170
|
-
|
|
170
|
+
# @private
|
|
171
|
+
def _write_attribute(...) = _require_attributes_initialized { super }
|
|
171
172
|
|
|
173
|
+
# @private
|
|
172
174
|
def attribute(...) = _require_attributes_initialized { super }
|
|
173
175
|
|
|
176
|
+
# @private
|
|
174
177
|
def _require_attributes_initialized
|
|
175
178
|
unless @attributes
|
|
176
|
-
raise ActiveRecordCompose::UninitializedAttribute
|
|
177
|
-
"No attributes have been set. Is proper initialization performed, such as calling `super` in `initialize`?"
|
|
179
|
+
raise ActiveRecordCompose::UninitializedAttribute.new(self)
|
|
178
180
|
end
|
|
179
181
|
|
|
180
182
|
yield
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "set"
|
|
3
4
|
require_relative "wrapped_model"
|
|
4
5
|
|
|
5
6
|
module ActiveRecordCompose
|
|
@@ -117,7 +118,7 @@ module ActiveRecordCompose
|
|
|
117
118
|
def symbol_proc_map
|
|
118
119
|
@symbol_proc_map ||=
|
|
119
120
|
Hash.new do |h, k|
|
|
120
|
-
h[k] = -> { owner.__send__(k) }
|
|
121
|
+
h[k] = -> { owner.__send__(k) } # steep:ignore
|
|
121
122
|
end
|
|
122
123
|
end
|
|
123
124
|
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module ActiveRecordCompose
|
|
4
|
+
# Generic Active Record Compose exception class.
|
|
5
|
+
#
|
|
6
|
+
class ActiveRecordComposeError < StandardError
|
|
7
|
+
end
|
|
8
|
+
|
|
4
9
|
# Occurs when a circular reference is detected in the containing model.
|
|
5
10
|
#
|
|
6
11
|
# @example
|
|
@@ -25,7 +30,7 @@ module ActiveRecordCompose
|
|
|
25
30
|
# inner.model = outer # There is a circular reference in the form outer > middle > inner > outer.
|
|
26
31
|
# outer.save #=> raises ActiveRecordCompose::CircularReferenceDetected
|
|
27
32
|
#
|
|
28
|
-
class CircularReferenceDetected <
|
|
33
|
+
class CircularReferenceDetected < ActiveRecordComposeError; end
|
|
29
34
|
|
|
30
35
|
# Occurs when accessing Attributes without initializing it.
|
|
31
36
|
#
|
|
@@ -40,5 +45,13 @@ module ActiveRecordCompose
|
|
|
40
45
|
# model = Model.new
|
|
41
46
|
# model.foo = 1 #=> raises ActiveRecordCompose::UninitializedAttribute
|
|
42
47
|
#
|
|
43
|
-
class UninitializedAttribute <
|
|
48
|
+
class UninitializedAttribute < ActiveRecordComposeError
|
|
49
|
+
attr_reader :record
|
|
50
|
+
|
|
51
|
+
def initialize(record = nil)
|
|
52
|
+
@record = record
|
|
53
|
+
message = "No attributes have been set. Is proper initialization performed, such as calling `super` in `initialize`?"
|
|
54
|
+
super(message)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
44
57
|
end
|
|
@@ -85,8 +85,8 @@ module ActiveRecordCompose
|
|
|
85
85
|
|
|
86
86
|
include ActiveRecordCompose::Attributes
|
|
87
87
|
include ActiveRecordCompose::Persistence
|
|
88
|
-
include ActiveRecordCompose::Validations
|
|
89
88
|
include ActiveRecordCompose::TransactionSupport
|
|
89
|
+
include ActiveRecordCompose::Validations
|
|
90
90
|
include ActiveRecordCompose::Inspectable
|
|
91
91
|
|
|
92
92
|
def initialize(attributes = {})
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ActiveRecordCompose
|
|
4
|
+
module TransactionSupport
|
|
5
|
+
# @private
|
|
6
|
+
# steep:ignore:start
|
|
7
|
+
|
|
8
|
+
# In older versions, the ActiveRecord::Transaction object is not passed to the block argument of #transaction.
|
|
9
|
+
# So instead, we define a transaction object that can be evaluated equivalently.
|
|
10
|
+
# This follow-up will no longer be necessary when support for Rails 7.1 is dropped.
|
|
11
|
+
#
|
|
12
|
+
class ActiveTransaction
|
|
13
|
+
def initialize(transaction)
|
|
14
|
+
@real_transaction = transaction
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
attr_reader :real_transaction
|
|
18
|
+
|
|
19
|
+
def open? = !closed?
|
|
20
|
+
|
|
21
|
+
def closed? = real_transaction&.state&.completed?
|
|
22
|
+
|
|
23
|
+
def ==(other)
|
|
24
|
+
return true if equal?(other)
|
|
25
|
+
return false unless self.class == other.class
|
|
26
|
+
|
|
27
|
+
real_transaction == other.real_transaction
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def eql?(other)
|
|
31
|
+
return true if equal?(other)
|
|
32
|
+
return false unless self.class == other.class
|
|
33
|
+
|
|
34
|
+
real_transaction.eql?(other.real_transaction)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def hash = real_transaction.hash
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# steep:ignore:end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "set"
|
|
4
|
+
|
|
5
|
+
module ActiveRecordCompose
|
|
6
|
+
module TransactionSupport
|
|
7
|
+
# @private
|
|
8
|
+
class TransactionCoordinator
|
|
9
|
+
def add_transaction(active_transaction)
|
|
10
|
+
transactions << active_transaction
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# The before_commit callback is controlled so that
|
|
14
|
+
# it runs just before the outermost transaction commits,
|
|
15
|
+
# but not just before any inner transactions commit.
|
|
16
|
+
#
|
|
17
|
+
def on_before_comitted
|
|
18
|
+
return unless final_transaction?
|
|
19
|
+
|
|
20
|
+
yield
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# It processes after_commit/after_rollback only immediately
|
|
24
|
+
# after all transactions are closed.
|
|
25
|
+
#
|
|
26
|
+
def on_after_transaction
|
|
27
|
+
return unless all_finished?
|
|
28
|
+
|
|
29
|
+
with_transaction_cleanup { yield }
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
def with_transaction_cleanup
|
|
35
|
+
yield
|
|
36
|
+
ensure
|
|
37
|
+
transactions.reject! { _1.closed? }
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def final_transaction? = transactions.one? { !_1.closed? }
|
|
41
|
+
|
|
42
|
+
def all_finished? = transactions.all? { _1.closed? }
|
|
43
|
+
|
|
44
|
+
def transactions = @transactions ||= Set.new
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "active_support/core_ext/module"
|
|
4
|
+
require_relative "transaction_support/active_transaction"
|
|
5
|
+
require_relative "transaction_support/transaction_coordinator"
|
|
4
6
|
|
|
5
7
|
module ActiveRecordCompose
|
|
6
8
|
module TransactionSupport
|
|
@@ -13,24 +15,26 @@ module ActiveRecordCompose
|
|
|
13
15
|
# steep:ignore:start
|
|
14
16
|
|
|
15
17
|
class_methods do
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
if ActiveRecord.version >= Gem::Version.new("7.2")
|
|
19
|
+
# @private
|
|
20
|
+
# @deprecated
|
|
21
|
+
def with_connection(...)
|
|
22
|
+
ActiveRecordCompose.deprecator.deprecation_warning(:with_connection, "Use `ActiveRecord::Base.with_connection` instead.")
|
|
23
|
+
ActiveRecord::Base.with_connection(...)
|
|
24
|
+
end
|
|
22
25
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
# @private
|
|
27
|
+
# @deprecated
|
|
28
|
+
def lease_connection(...)
|
|
29
|
+
ActiveRecordCompose.deprecator.deprecation_warning(:lease_connection, "Use `ActiveRecord::Base.lease_connection` instead.")
|
|
30
|
+
ActiveRecord::Base.lease_connection(...)
|
|
31
|
+
end
|
|
28
32
|
end
|
|
29
33
|
|
|
30
34
|
# @private
|
|
31
35
|
# @deprecated
|
|
32
36
|
def connection(...)
|
|
33
|
-
|
|
37
|
+
ActiveRecordCompose.deprecator.deprecation_warning(:connection, "Use `ActiveRecord::Base.connection` instead.")
|
|
34
38
|
ActiveRecord::Base.connection(...)
|
|
35
39
|
end
|
|
36
40
|
end
|
|
@@ -86,17 +90,17 @@ module ActiveRecordCompose
|
|
|
86
90
|
|
|
87
91
|
# @private
|
|
88
92
|
def before_committed!
|
|
89
|
-
_run_before_commit_callbacks
|
|
93
|
+
transaction_coordinator.on_before_comitted { _run_before_commit_callbacks }
|
|
90
94
|
end
|
|
91
95
|
|
|
92
96
|
# @private
|
|
93
97
|
def committed!(should_run_callbacks: true)
|
|
94
|
-
_run_commit_callbacks if should_run_callbacks
|
|
98
|
+
transaction_coordinator.on_after_transaction { _run_commit_callbacks if should_run_callbacks }
|
|
95
99
|
end
|
|
96
100
|
|
|
97
101
|
# @private
|
|
98
102
|
def rolledback!(force_restore_state: false, should_run_callbacks: true)
|
|
99
|
-
_run_rollback_callbacks if should_run_callbacks
|
|
103
|
+
transaction_coordinator.on_after_transaction { _run_rollback_callbacks if should_run_callbacks }
|
|
100
104
|
end
|
|
101
105
|
end
|
|
102
106
|
|
|
@@ -104,30 +108,59 @@ module ActiveRecordCompose
|
|
|
104
108
|
|
|
105
109
|
def save!(**options) = with_transaction_returning_status { super }
|
|
106
110
|
|
|
107
|
-
private
|
|
108
|
-
|
|
109
111
|
# @private
|
|
110
|
-
def
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
def connection_pools
|
|
113
|
+
pools =
|
|
114
|
+
models.compact.flat_map do |model|
|
|
115
|
+
if model.is_a?(ActiveRecordCompose::TransactionSupport)
|
|
116
|
+
model.connection_pools
|
|
117
|
+
elsif model.is_a?(ActiveRecord::Base)
|
|
118
|
+
connection_pool(ar_class: model.class)
|
|
119
|
+
else
|
|
120
|
+
[] # : Array[ActiveRecord::ConnectionAdapters::ConnectionPool]
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
pools << connection_pool if pools.blank?
|
|
124
|
+
pools.uniq
|
|
125
|
+
end
|
|
114
126
|
|
|
115
|
-
|
|
116
|
-
connection.add_transaction_record(self, ensure_finalize || has_transactional_callbacks?)
|
|
127
|
+
private
|
|
117
128
|
|
|
118
|
-
|
|
119
|
-
|
|
129
|
+
# @private
|
|
130
|
+
def with_transaction_returning_status(&block)
|
|
131
|
+
procs = connection_pools.inject(block) do |inner_proc, pool|
|
|
132
|
+
-> do
|
|
133
|
+
pool.with_connection do |connection|
|
|
134
|
+
with_pool_transaction_isolation_level(connection) do
|
|
135
|
+
ensure_finalize = !connection.transaction_open?
|
|
136
|
+
|
|
137
|
+
connection.transaction do |tran|
|
|
138
|
+
tran ||= ActiveTransaction.new(connection.current_transaction) # steep:ignore
|
|
139
|
+
transaction_coordinator.add_transaction(tran)
|
|
140
|
+
|
|
141
|
+
begin
|
|
142
|
+
inner_proc.call.tap { raise ActiveRecord::Rollback unless _1 }
|
|
143
|
+
ensure
|
|
144
|
+
connection.add_transaction_record(self, ensure_finalize || has_transactional_callbacks?)
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
end
|
|
120
149
|
end
|
|
121
150
|
end
|
|
151
|
+
procs.call || false
|
|
122
152
|
end
|
|
123
153
|
|
|
154
|
+
# @private
|
|
155
|
+
def transaction_coordinator = @transaction_coordinator ||= TransactionCoordinator.new
|
|
156
|
+
|
|
124
157
|
# @private
|
|
125
158
|
def default_ar_class = ActiveRecord::Base
|
|
126
159
|
|
|
127
160
|
# @private
|
|
128
161
|
def connection_pool(ar_class: default_ar_class)
|
|
129
162
|
connection_specification_name = ar_class.connection_specification_name
|
|
130
|
-
role = ar_class.current_role
|
|
163
|
+
role = ar_class.current_role # steep:ignore
|
|
131
164
|
shard = ar_class.current_shard # steep:ignore
|
|
132
165
|
connection_handler = ar_class.connection_handler # steep:ignore
|
|
133
166
|
retrieve_options = { role:, shard: }
|
|
@@ -139,7 +172,7 @@ module ActiveRecordCompose
|
|
|
139
172
|
# @private
|
|
140
173
|
def with_pool_transaction_isolation_level(connection, &block)
|
|
141
174
|
if ActiveRecord.gem_version.release >= Gem::Version.new("8.1.0")
|
|
142
|
-
isolation_level = ActiveRecord.default_transaction_isolation_level
|
|
175
|
+
isolation_level = ActiveRecord.default_transaction_isolation_level
|
|
143
176
|
connection.pool.with_pool_transaction_isolation_level(isolation_level, connection.transaction_open?, &block)
|
|
144
177
|
else
|
|
145
178
|
block.call
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module ActiveRecordCompose
|
|
4
|
-
VERSION = "1.
|
|
4
|
+
VERSION = "1.4.0"
|
|
5
|
+
|
|
6
|
+
class << self
|
|
7
|
+
def version = Gem::Version.new(VERSION)
|
|
8
|
+
|
|
9
|
+
private
|
|
10
|
+
|
|
11
|
+
# @private
|
|
12
|
+
def next_major_version
|
|
13
|
+
version.segments.first + 1 # steep:ignore
|
|
14
|
+
end
|
|
15
|
+
end
|
|
5
16
|
end
|
|
@@ -11,6 +11,10 @@ require_relative "active_record_compose/model"
|
|
|
11
11
|
# Most of the functionality resides in {ActiveRecordCompose::Model}.
|
|
12
12
|
#
|
|
13
13
|
module ActiveRecordCompose
|
|
14
|
+
# @private
|
|
15
|
+
def self.deprecator
|
|
16
|
+
@deprecator ||= ActiveSupport::Deprecation.new(next_major_version, "ActiveRecordCompose") # steep:ignore
|
|
17
|
+
end
|
|
14
18
|
end
|
|
15
19
|
|
|
16
20
|
require "active_record_compose/railtie" if defined?(::Rails::Railtie)
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
module ActiveRecordCompose
|
|
2
|
+
private
|
|
3
|
+
def self.next_major_version: () -> Integer
|
|
4
|
+
|
|
2
5
|
module Attributes
|
|
3
6
|
extend ActiveSupport::Concern
|
|
4
7
|
include ActiveModel::Attributes
|
|
@@ -118,6 +121,8 @@ module ActiveRecordCompose
|
|
|
118
121
|
include ActiveSupport::Callbacks
|
|
119
122
|
extend ActiveSupport::Callbacks::ClassMethods
|
|
120
123
|
|
|
124
|
+
@transaction_coordinator: ActiveRecordCompose::TransactionSupport::TransactionCoordinator
|
|
125
|
+
|
|
121
126
|
def self.before_commit: (*untyped) -> untyped
|
|
122
127
|
def self.after_commit: (*untyped) -> untyped
|
|
123
128
|
def self.after_rollback: (*untyped) -> untyped
|
|
@@ -127,11 +132,28 @@ module ActiveRecordCompose
|
|
|
127
132
|
def _run_before_commit_callbacks: () -> untyped
|
|
128
133
|
def _run_commit_callbacks: () -> untyped
|
|
129
134
|
def _run_rollback_callbacks: () -> untyped
|
|
135
|
+
def connection_pools: () -> Array[ActiveRecord::ConnectionAdapters::ConnectionPool]
|
|
130
136
|
|
|
131
137
|
private
|
|
138
|
+
def models: -> ComposedCollection
|
|
132
139
|
def default_ar_class: -> singleton(ActiveRecord::Base)
|
|
133
140
|
def connection_pool: (?ar_class: singleton(ActiveRecord::Base)) -> ActiveRecord::ConnectionAdapters::ConnectionPool
|
|
134
141
|
def with_pool_transaction_isolation_level: [T] (ActiveRecord::ConnectionAdapters::AbstractAdapter) { () -> T } -> T
|
|
142
|
+
def transaction_coordinator: () -> ActiveRecordCompose::TransactionSupport::TransactionCoordinator
|
|
143
|
+
|
|
144
|
+
class TransactionCoordinator
|
|
145
|
+
@transactions: Set[ActiveRecord::ConnectionAdapters::Transaction]
|
|
146
|
+
|
|
147
|
+
def add_transaction: (ActiveRecord::ConnectionAdapters::Transaction) -> void
|
|
148
|
+
def on_after_transaction: () { () -> void } -> void
|
|
149
|
+
def on_before_comitted: () { () -> void } -> void
|
|
150
|
+
|
|
151
|
+
private
|
|
152
|
+
def final_transaction?: -> bool
|
|
153
|
+
def all_finished?: -> bool
|
|
154
|
+
def transactions: () -> Set[ActiveRecord::ConnectionAdapters::Transaction]
|
|
155
|
+
def with_transaction_cleanup: () { () -> void } -> void
|
|
156
|
+
end
|
|
135
157
|
end
|
|
136
158
|
|
|
137
159
|
module Persistence
|
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
module ActiveRecordCompose
|
|
5
5
|
VERSION: String
|
|
6
6
|
|
|
7
|
+
def self.version: () -> Gem::Version
|
|
8
|
+
def self.deprecator: () -> ActiveSupport::Deprecation
|
|
9
|
+
|
|
7
10
|
interface _ARLike
|
|
8
11
|
def save: (**untyped options) -> bool
|
|
9
12
|
def save!: (**untyped options) -> untyped
|
|
@@ -36,6 +39,9 @@ module ActiveRecordCompose
|
|
|
36
39
|
type destroy_context_type = ((^() -> boolish) | (^(ar_like) -> boolish))
|
|
37
40
|
type condition_type = ((^() -> boolish) | (^(ar_like) -> boolish))
|
|
38
41
|
|
|
42
|
+
class ActiveRecordComposeError < StandardError
|
|
43
|
+
end
|
|
44
|
+
|
|
39
45
|
class ComposedCollection
|
|
40
46
|
include ::Enumerable[ar_like]
|
|
41
47
|
|
|
@@ -47,7 +53,7 @@ module ActiveRecordCompose
|
|
|
47
53
|
def delete: (ar_like) -> ComposedCollection?
|
|
48
54
|
end
|
|
49
55
|
|
|
50
|
-
class CircularReferenceDetected <
|
|
56
|
+
class CircularReferenceDetected < ActiveRecordComposeError
|
|
51
57
|
end
|
|
52
58
|
|
|
53
59
|
class Model
|
|
@@ -99,6 +105,9 @@ module ActiveRecordCompose
|
|
|
99
105
|
extend Rails::Initializable::ClassMethods
|
|
100
106
|
end
|
|
101
107
|
|
|
102
|
-
class UninitializedAttribute <
|
|
108
|
+
class UninitializedAttribute < ActiveRecordComposeError
|
|
109
|
+
def initialize: (?untyped) -> void
|
|
110
|
+
|
|
111
|
+
attr_reader record: untyped
|
|
103
112
|
end
|
|
104
113
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: active_record_compose
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- hamajyotan
|
|
@@ -56,6 +56,8 @@ files:
|
|
|
56
56
|
- lib/active_record_compose/persistence.rb
|
|
57
57
|
- lib/active_record_compose/railtie.rb
|
|
58
58
|
- lib/active_record_compose/transaction_support.rb
|
|
59
|
+
- lib/active_record_compose/transaction_support/active_transaction.rb
|
|
60
|
+
- lib/active_record_compose/transaction_support/transaction_coordinator.rb
|
|
59
61
|
- lib/active_record_compose/validations.rb
|
|
60
62
|
- lib/active_record_compose/version.rb
|
|
61
63
|
- lib/active_record_compose/wrapped_model.rb
|
|
@@ -84,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
84
86
|
- !ruby/object:Gem::Version
|
|
85
87
|
version: '0'
|
|
86
88
|
requirements: []
|
|
87
|
-
rubygems_version: 4.0.
|
|
89
|
+
rubygems_version: 4.0.16
|
|
88
90
|
specification_version: 4
|
|
89
91
|
summary: activemodel form object pattern
|
|
90
92
|
test_files: []
|