active_form_objects 2.0.3 → 2.0.4

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: 32bbcd1a6684a09bb606d3a6848f52c32afaf66f75df93f6fd07bd997c5f06ab
4
- data.tar.gz: c10d1950dcffeccdf608792121c8aa662514a362bda69c12d252acabe09916bc
3
+ metadata.gz: 2daaa8dd6cc58ada79b0fbab645c19bdc3f8ba9439d5c2c58e2a9db8d45b64ff
4
+ data.tar.gz: 2ca8cb23a9f2b1118cfbf699463d64e1e6db8d9a3804ce8e56abffbdbef846e5
5
5
  SHA512:
6
- metadata.gz: bd52ac4dd87b46db10f493409d0ef3b2040e995be7d9c158bba8b51dc32f1765765f553813792bba9f064945c0ccb7c6385241749da6ba68de4bb1e59ed961e4
7
- data.tar.gz: 5f420c1413ec7d1386c0a20288b67ca71b42fa950e3edf72cf0273987de6e040b92e7718e26e37f6527719a57d20a64aa8f5cef8bedc9accdaa50e9981a744a9
6
+ metadata.gz: c2f92a20ca5941af70874c8bce8d7c4cf1a963fe61c933e08a9321e67212a8dfc4c8a88936ded00a063f07825b26d44185fbc50c667e8ded2ce22b3ce10f67a9
7
+ data.tar.gz: 49b4ab98dc7d917878ef897a080ce95b61d11345077ee5c93554ac64e1472ad474e9f7ba4ba45cb5c05887c3bb36b5c32640a5712ee3d5b034edf12c3b62a466
@@ -4,10 +4,11 @@ require 'active_support/core_ext/hash/indifferent_access'
4
4
  require_relative 'dsl/debug'
5
5
  require_relative 'dsl/relations'
6
6
  require_relative 'dsl/attributes'
7
+ require_relative 'dsl/error_handling'
8
+ require_relative 'dsl/polymorphs'
7
9
  require_relative 'dsl/delegates'
8
10
  require_relative 'dsl/savings'
9
11
  require_relative 'dsl/resource'
10
- require_relative 'dsl/polymorphs'
11
12
  require_relative 'dsl/scopes'
12
13
  require_relative 'dsl/hooks'
13
14
 
@@ -26,6 +27,7 @@ module ActiveFormObjects
26
27
  include Dsl::Debug
27
28
  include Dsl::Resource
28
29
  include Dsl::Attributes
30
+ include Dsl::ErrorHandling
29
31
  include Dsl::Relations
30
32
  include Dsl::Polymorphs
31
33
  include Dsl::Delegates
@@ -0,0 +1,14 @@
1
+ module Dsl
2
+ module ErrorHandling
3
+ def map_errors_to(form)
4
+ yield
5
+ rescue ActiveRecord::RecordInvalid, ActiveModel::ValidationError => e
6
+ record = (e.try(:record) || e.model)
7
+ initial_messages = record.errors.messages.as_json
8
+ record.errors.clear
9
+ record.errors.messages[form] = initial_messages
10
+
11
+ raise ActiveModel::ValidationError, record
12
+ end
13
+ end
14
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_form_objects
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michaël Villeneuve
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-26 00:00:00.000000000 Z
11
+ date: 2019-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '4.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: method_source
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.9.2
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.9.2
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: ruby_parser
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -90,6 +104,7 @@ files:
90
104
  - lib/dsl/attributes.rb
91
105
  - lib/dsl/debug.rb
92
106
  - lib/dsl/delegates.rb
107
+ - lib/dsl/error_handling.rb
93
108
  - lib/dsl/errors.rb
94
109
  - lib/dsl/hooks.rb
95
110
  - lib/dsl/polymorphs.rb
@@ -127,7 +142,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
142
  - !ruby/object:Gem::Version
128
143
  version: '0'
129
144
  requirements: []
130
- rubygems_version: 3.0.1
145
+ rubyforge_project:
146
+ rubygems_version: 2.7.3
131
147
  signing_key:
132
148
  specification_version: 4
133
149
  summary: A step toward an hexagonal Rails architecture