active_record_compose 0.1.4 → 0.1.5
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 +4 -0
- data/lib/active_record_compose/model.rb +15 -3
- data/lib/active_record_compose/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1638c67c9c0cebca26544e01db7b210a0bde69d581471d3fbe771ada25c124b9
|
4
|
+
data.tar.gz: d7c43f6b81793f349a2f4e33132616b8dca2971a607d49ecedaa102fed1b1f5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b9aca1764d28fdeb52b0d32fdc6fb0ca13e6c1891efd47335f18660935b36ae64be28cb1a6db08bf1b8b0d3d65aa9daa94bccdea03982112fd59386e57e7e50
|
7
|
+
data.tar.gz: 6888e57191546c7d698bde1f2741f280b930d8b8f1f648c02ec0cd025d54a8f89d88bb4dd1cbe0feaf0e37e5f1fd8d4885032259481536edcd73aad1d067aed8
|
data/CHANGELOG.md
CHANGED
@@ -28,7 +28,11 @@ module ActiveRecordCompose
|
|
28
28
|
save_in_transaction { run_callbacks(:save) { save_models } }
|
29
29
|
end
|
30
30
|
|
31
|
-
def save!
|
31
|
+
def save!
|
32
|
+
valid? || raise_validation_error
|
33
|
+
|
34
|
+
save_in_transaction { run_callbacks(:save) { save_models } } || raise_on_save_error
|
35
|
+
end
|
32
36
|
|
33
37
|
# Behavior is same to `#save`, but `before_create` and `after_create` hooks fires.
|
34
38
|
#
|
@@ -65,7 +69,10 @@ module ActiveRecordCompose
|
|
65
69
|
# Behavior is same to `#create`, but raises an exception prematurely on failure.
|
66
70
|
#
|
67
71
|
def create!(attributes = {})
|
68
|
-
|
72
|
+
assign_attributes(attributes)
|
73
|
+
valid? || raise_validation_error
|
74
|
+
|
75
|
+
save_in_transaction { run_callbacks(:save) { run_callbacks(:create) { save_models } } } || raise_on_save_error
|
69
76
|
end
|
70
77
|
|
71
78
|
# Behavior is same to `#save`, but `before_update` and `after_update` hooks fires.
|
@@ -103,7 +110,10 @@ module ActiveRecordCompose
|
|
103
110
|
# Behavior is same to `#update`, but raises an exception prematurely on failure.
|
104
111
|
#
|
105
112
|
def update!(attributes = {})
|
106
|
-
|
113
|
+
assign_attributes(attributes)
|
114
|
+
valid? || raise_validation_error
|
115
|
+
|
116
|
+
save_in_transaction { run_callbacks(:save) { run_callbacks(:update) { save_models } } } || raise_on_save_error
|
107
117
|
end
|
108
118
|
|
109
119
|
private
|
@@ -130,6 +140,8 @@ module ActiveRecordCompose
|
|
130
140
|
|
131
141
|
def save_models = wrapped_models.all? { _1.save! }
|
132
142
|
|
143
|
+
def raise_validation_error = raise ActiveRecord::RecordInvalid, self
|
144
|
+
|
133
145
|
def raise_on_save_error = raise ActiveRecord::RecordNotSaved.new('Failed to save the model.', self)
|
134
146
|
end
|
135
147
|
end
|
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.5
|
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-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -65,7 +65,7 @@ metadata:
|
|
65
65
|
homepage_uri: https://github.com/hamajyotan/active_record_compose
|
66
66
|
source_code_uri: https://github.com/hamajyotan/active_record_compose
|
67
67
|
changelog_uri: https://github.com/hamajyotan/active_record_compose/blob/main/CHANGELOG.md
|
68
|
-
documentation_uri: https://www.rubydoc.info/gems/active_record_compose/0.1.
|
68
|
+
documentation_uri: https://www.rubydoc.info/gems/active_record_compose/0.1.5
|
69
69
|
rubygems_mfa_required: 'true'
|
70
70
|
post_install_message:
|
71
71
|
rdoc_options: []
|