active_record_compose 0.1.2 → 0.1.4
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 +8 -0
- data/lib/active_record_compose/model.rb +5 -5
- data/lib/active_record_compose/version.rb +1 -1
- data/lib/active_record_compose.rb +0 -1
- metadata +6 -7
- data/lib/active_record_compose/error.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f0306635ed35d2888c6a8f5ddc3d0ac5b04ba6aee2a2f6eaba304e57bc05ebc
|
4
|
+
data.tar.gz: 3fdd952bc0c2b93a448f2be8b8d9a441afb20d635eab9a32ed05b6a837978d7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd5b513cfe39716ea5caf87be10e5fa9e514d134bed93b54456ce8bdf071a9ec5d336efbef8f609c4d3857e3763e4ed75b757db3145ca3cf4c7e79b6c98d6826
|
7
|
+
data.tar.gz: 5e92989ed498e4e244692031231ad2f3c738025a1d066f2146f4ac36b37107143c46d131a30d7fb84df22ac703d230c9062446b5049a60012dd3209fdabe5e88
|
data/CHANGELOG.md
CHANGED
@@ -12,8 +12,6 @@ module ActiveRecordCompose
|
|
12
12
|
|
13
13
|
include ActiveRecordCompose::DelegateAttribute
|
14
14
|
|
15
|
-
class_attribute :error_class_on_save_error, instance_writer: false, default: ActiveRecordCompose::RecordNotSaved
|
16
|
-
|
17
15
|
define_model_callbacks :save
|
18
16
|
define_model_callbacks :create
|
19
17
|
define_model_callbacks :update
|
@@ -30,7 +28,7 @@ module ActiveRecordCompose
|
|
30
28
|
save_in_transaction { run_callbacks(:save) { save_models } }
|
31
29
|
end
|
32
30
|
|
33
|
-
def save! = save ||
|
31
|
+
def save! = save || raise_on_save_error
|
34
32
|
|
35
33
|
# Behavior is same to `#save`, but `before_create` and `after_create` hooks fires.
|
36
34
|
#
|
@@ -67,7 +65,7 @@ module ActiveRecordCompose
|
|
67
65
|
# Behavior is same to `#create`, but raises an exception prematurely on failure.
|
68
66
|
#
|
69
67
|
def create!(attributes = {})
|
70
|
-
create(attributes) ||
|
68
|
+
create(attributes) || raise_on_save_error
|
71
69
|
end
|
72
70
|
|
73
71
|
# Behavior is same to `#save`, but `before_update` and `after_update` hooks fires.
|
@@ -105,7 +103,7 @@ module ActiveRecordCompose
|
|
105
103
|
# Behavior is same to `#update`, but raises an exception prematurely on failure.
|
106
104
|
#
|
107
105
|
def update!(attributes = {})
|
108
|
-
update(attributes) ||
|
106
|
+
update(attributes) || raise_on_save_error
|
109
107
|
end
|
110
108
|
|
111
109
|
private
|
@@ -131,5 +129,7 @@ module ActiveRecordCompose
|
|
131
129
|
end
|
132
130
|
|
133
131
|
def save_models = wrapped_models.all? { _1.save! }
|
132
|
+
|
133
|
+
def raise_on_save_error = raise ActiveRecord::RecordNotSaved.new('Failed to save the model.', self)
|
134
134
|
end
|
135
135
|
end
|
@@ -3,7 +3,6 @@
|
|
3
3
|
require 'active_record'
|
4
4
|
|
5
5
|
require_relative 'active_record_compose/version'
|
6
|
-
require_relative 'active_record_compose/error'
|
7
6
|
require_relative 'active_record_compose/inner_model'
|
8
7
|
require_relative 'active_record_compose/inner_model_collection'
|
9
8
|
require_relative 'active_record_compose/model'
|
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: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hamajyotan
|
@@ -54,19 +54,18 @@ files:
|
|
54
54
|
- Rakefile
|
55
55
|
- lib/active_record_compose.rb
|
56
56
|
- lib/active_record_compose/delegate_attribute.rb
|
57
|
-
- lib/active_record_compose/error.rb
|
58
57
|
- lib/active_record_compose/inner_model.rb
|
59
58
|
- lib/active_record_compose/inner_model_collection.rb
|
60
59
|
- lib/active_record_compose/model.rb
|
61
60
|
- lib/active_record_compose/version.rb
|
62
|
-
homepage: https://github.com/active_record_compose
|
61
|
+
homepage: https://github.com/hamajyotan/active_record_compose
|
63
62
|
licenses:
|
64
63
|
- MIT
|
65
64
|
metadata:
|
66
|
-
homepage_uri: https://github.com/active_record_compose
|
67
|
-
source_code_uri: https://github.com/active_record_compose
|
68
|
-
changelog_uri: https://github.com/active_record_compose/blob/main/CHANGELOG.md
|
69
|
-
documentation_uri: https://www.rubydoc.info/gems/active_record_compose/0.1.
|
65
|
+
homepage_uri: https://github.com/hamajyotan/active_record_compose
|
66
|
+
source_code_uri: https://github.com/hamajyotan/active_record_compose
|
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.4
|
70
69
|
rubygems_mfa_required: 'true'
|
71
70
|
post_install_message:
|
72
71
|
rdoc_options: []
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ActiveRecordCompose
|
4
|
-
class Error < ::StandardError; end
|
5
|
-
|
6
|
-
class RecordNotSaved < ::ActiveRecordCompose::Error
|
7
|
-
def initialize(message, record)
|
8
|
-
super(message)
|
9
|
-
@record = record
|
10
|
-
end
|
11
|
-
|
12
|
-
attr_reader :record
|
13
|
-
end
|
14
|
-
end
|