reform-rails 0.2.1 → 0.2.2
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/.travis.yml +1 -0
- data/CHANGES.md +4 -0
- data/Gemfile +2 -2
- data/LICENSE.txt +1 -1
- data/lib/reform/active_record.rb +1 -0
- data/lib/reform/form/active_model/result.rb +15 -0
- data/lib/reform/form/active_model/validations.rb +3 -2
- data/lib/reform/rails/version.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 754bad405b747f3fb7e2ea5bfb46ca9e32262eb0f17c85d9804312da30adaa6f
|
4
|
+
data.tar.gz: 1a5643a5b733a4f536964e4ea33b5a38ee645cd752696d337a97cb824b72f442
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9f24f96751b877f6dd57da25502dbf7bdc23362e255ff78b677c18c3d51a3ffdc2b30ea101831fb2ce8a2b8e1cef665e968cd57c7394e0d897e8a8d2054eab3
|
7
|
+
data.tar.gz: 129b85d74bcb7c45552991b0d76af9f4955119a9a57fb44d56620970ef935f8a8df3667db1b5088c5836c1c0f8c72367c8d80a9876448e21019cf5a3026de66d
|
data/.travis.yml
CHANGED
data/CHANGES.md
CHANGED
data/Gemfile
CHANGED
@@ -20,12 +20,12 @@ rails_version = ENV.fetch("RAILS_VERSION", "6.0.0")
|
|
20
20
|
|
21
21
|
# bored of wrestling with rails...
|
22
22
|
|
23
|
-
gem("mongoid", "< 7.0") unless rails_version.
|
23
|
+
gem("mongoid", "< 7.0") unless rails_version.to_i >= 6
|
24
24
|
|
25
25
|
|
26
26
|
gem "activerecord", "~> #{rails_version}"
|
27
27
|
gem "railties", "~> #{rails_version}"
|
28
|
-
if rails_version.
|
28
|
+
if rails_version.to_i >= 6
|
29
29
|
gem "sqlite3", "~> 1.4"
|
30
30
|
else
|
31
31
|
gem "sqlite3", "~> 1.3", "< 1.4"
|
data/LICENSE.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2015-
|
3
|
+
Copyright (c) 2015-2021 Nick Sutterer
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/lib/reform/active_record.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
class Reform::Contract::Result
|
2
|
+
private
|
3
|
+
|
4
|
+
def filter_for(method, *args)
|
5
|
+
@results.collect { |r| r.public_send(method, *args).to_h }
|
6
|
+
.inject({}) { |hah, err| hah.merge(err) { |key, old_v, new_v| (new_v.is_a?(Array) ? (old_v |= new_v) : old_v.merge(new_v)) } }
|
7
|
+
.find_all { |k, v| # filter :nested=>{:something=>["too nested!"]} #DISCUSS: do we want that here?
|
8
|
+
if v.is_a?(Hash)
|
9
|
+
nested_errors = v.select { |attr_key, val| attr_key.is_a?(Integer) && val.is_a?(Array) && val.any? }
|
10
|
+
v = nested_errors.to_a if nested_errors.any?
|
11
|
+
end
|
12
|
+
v.is_a?(Array) || v.class.to_s == "ActiveModel::DeprecationHandlingMessageArray"
|
13
|
+
}.to_h
|
14
|
+
end
|
15
|
+
end
|
@@ -143,7 +143,8 @@ module Reform
|
|
143
143
|
|
144
144
|
def add(key, error_text)
|
145
145
|
# use rails magic to get the correct error_text and make sure we still update details and fields
|
146
|
-
|
146
|
+
error = @amv_errors.add(key, error_text)
|
147
|
+
error = [error.message] unless error.is_a?(Array)
|
147
148
|
|
148
149
|
# using error_text instead of text to either keep the symbol which will be
|
149
150
|
# magically replaced with the translate or directly the string - this is also
|
@@ -153,7 +154,7 @@ module Reform
|
|
153
154
|
|
154
155
|
# but since messages method is actually already defined in `Reform::Contract::Result::Errors
|
155
156
|
# we need to update the @dotted_errors instance variable to add or merge a new error
|
156
|
-
@dotted_errors.key?(key) ? @dotted_errors[key] |=
|
157
|
+
@dotted_errors.key?(key) ? @dotted_errors[key] |= error : @dotted_errors[key] = error
|
157
158
|
instance_variable_set(:@dotted_errors, @dotted_errors)
|
158
159
|
end
|
159
160
|
|
data/lib/reform/rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reform-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Sutterer
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: reform
|
@@ -66,6 +66,7 @@ files:
|
|
66
66
|
- lib/reform/form/active_model/form_builder_methods.rb
|
67
67
|
- lib/reform/form/active_model/model_reflections.rb
|
68
68
|
- lib/reform/form/active_model/model_validations.rb
|
69
|
+
- lib/reform/form/active_model/result.rb
|
69
70
|
- lib/reform/form/active_model/validations.rb
|
70
71
|
- lib/reform/form/active_record.rb
|
71
72
|
- lib/reform/form/mongoid.rb
|
@@ -81,7 +82,7 @@ homepage: https://github.com/trailblazer/reform-rails
|
|
81
82
|
licenses:
|
82
83
|
- MIT
|
83
84
|
metadata: {}
|
84
|
-
post_install_message:
|
85
|
+
post_install_message:
|
85
86
|
rdoc_options: []
|
86
87
|
require_paths:
|
87
88
|
- lib
|
@@ -96,8 +97,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
97
|
- !ruby/object:Gem::Version
|
97
98
|
version: '0'
|
98
99
|
requirements: []
|
99
|
-
rubygems_version: 3.
|
100
|
-
signing_key:
|
100
|
+
rubygems_version: 3.2.3
|
101
|
+
signing_key:
|
101
102
|
specification_version: 4
|
102
103
|
summary: Automatically load and include all common Rails form features.
|
103
104
|
test_files: []
|