active_record_compose 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8e8c6c04b96e3396f6718d7bfbbf8867dce32cf34b9235ea2d37609c9e84dfb
|
4
|
+
data.tar.gz: c05ca6adb42a249a813ef250ea48fe05c72b073408bf3e5503acdb16df9cf585
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c3e646ab33c317647fa533e6d652e9b28fe442d337385d9505f2adafc65aaa75a7c3e6fad86cf869f3842b6c5ac8eebc05690e12547c76ccacdc3c08ca8c4e8
|
7
|
+
data.tar.gz: 1dcaf9de91f6b59a41c7848c969880290c5cb5288e1abba45de07a41b030d3f3d2e6312eca37ac120556d9233b62184a11d410ce208202adf56c9cc00e74acdf
|
data/CHANGELOG.md
CHANGED
@@ -31,7 +31,7 @@ module ActiveRecordCompose
|
|
31
31
|
def save
|
32
32
|
return false if invalid?
|
33
33
|
|
34
|
-
save_in_transaction { save_models }
|
34
|
+
save_in_transaction { save_models(bang: false) }
|
35
35
|
end
|
36
36
|
|
37
37
|
# Save the models that exist in models.
|
@@ -42,7 +42,7 @@ module ActiveRecordCompose
|
|
42
42
|
def save!
|
43
43
|
valid? || raise_validation_error
|
44
44
|
|
45
|
-
save_in_transaction { save_models } || raise_on_save_error
|
45
|
+
save_in_transaction { save_models(bang: true) } || raise_on_save_error
|
46
46
|
end
|
47
47
|
|
48
48
|
# Behavior is same to `#save`, but `before_create` and `after_create` hooks fires.
|
@@ -74,7 +74,7 @@ module ActiveRecordCompose
|
|
74
74
|
assign_attributes(attributes)
|
75
75
|
return false if invalid?
|
76
76
|
|
77
|
-
save_in_transaction { run_callbacks(:create) { save_models } }
|
77
|
+
save_in_transaction { run_callbacks(:create) { save_models(bang: false) } }
|
78
78
|
end
|
79
79
|
|
80
80
|
# Behavior is same to `#create`, but raises an exception prematurely on failure.
|
@@ -83,7 +83,7 @@ module ActiveRecordCompose
|
|
83
83
|
assign_attributes(attributes)
|
84
84
|
valid? || raise_validation_error
|
85
85
|
|
86
|
-
save_in_transaction { run_callbacks(:create) { save_models } } || raise_on_save_error
|
86
|
+
save_in_transaction { run_callbacks(:create) { save_models(bang: true) } } || raise_on_save_error
|
87
87
|
end
|
88
88
|
|
89
89
|
# Behavior is same to `#save`, but `before_update` and `after_update` hooks fires.
|
@@ -115,7 +115,7 @@ module ActiveRecordCompose
|
|
115
115
|
assign_attributes(attributes)
|
116
116
|
return false if invalid?
|
117
117
|
|
118
|
-
save_in_transaction { run_callbacks(:update) { save_models } }
|
118
|
+
save_in_transaction { run_callbacks(:update) { save_models(bang: false) } }
|
119
119
|
end
|
120
120
|
|
121
121
|
# Behavior is same to `#update`, but raises an exception prematurely on failure.
|
@@ -124,7 +124,7 @@ module ActiveRecordCompose
|
|
124
124
|
assign_attributes(attributes)
|
125
125
|
valid? || raise_validation_error
|
126
126
|
|
127
|
-
save_in_transaction { run_callbacks(:update) { save_models } } || raise_on_save_error
|
127
|
+
save_in_transaction { run_callbacks(:update) { save_models(bang: true) } } || raise_on_save_error
|
128
128
|
end
|
129
129
|
|
130
130
|
private
|
@@ -135,10 +135,10 @@ module ActiveRecordCompose
|
|
135
135
|
|
136
136
|
def validate_models = wrapped_models.select { _1.invalid? }.each { errors.merge!(_1) }
|
137
137
|
|
138
|
-
def save_in_transaction(
|
138
|
+
def save_in_transaction(...)
|
139
139
|
run_callbacks(:commit) do
|
140
140
|
result = ::ActiveRecord::Base.transaction do
|
141
|
-
raise ActiveRecord::Rollback unless run_callbacks(:save,
|
141
|
+
raise ActiveRecord::Rollback unless run_callbacks(:save, ...)
|
142
142
|
|
143
143
|
true
|
144
144
|
end
|
@@ -149,7 +149,7 @@ module ActiveRecordCompose
|
|
149
149
|
end.present?
|
150
150
|
end
|
151
151
|
|
152
|
-
def save_models = wrapped_models.all? { _1.save! }
|
152
|
+
def save_models(bang:) = wrapped_models.all? { bang ? _1.save! : _1.save }
|
153
153
|
|
154
154
|
def raise_validation_error = raise ActiveRecord::RecordInvalid, self
|
155
155
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record_compose
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hamajyotan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01-
|
11
|
+
date: 2024-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -51,7 +51,7 @@ metadata:
|
|
51
51
|
homepage_uri: https://github.com/hamajyotan/active_record_compose
|
52
52
|
source_code_uri: https://github.com/hamajyotan/active_record_compose
|
53
53
|
changelog_uri: https://github.com/hamajyotan/active_record_compose/blob/main/CHANGELOG.md
|
54
|
-
documentation_uri: https://www.rubydoc.info/gems/active_record_compose/0.1.
|
54
|
+
documentation_uri: https://www.rubydoc.info/gems/active_record_compose/0.1.8
|
55
55
|
rubygems_mfa_required: 'true'
|
56
56
|
post_install_message:
|
57
57
|
rdoc_options: []
|