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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f960a673533faebc84862cc0a7161d2b8c09c8d9c473af55041b5d9e4cb69fe1
4
- data.tar.gz: 6c78405ee3b1a2c27aa24e1afde65b0caf400e4593f9004f22afedd3113d1857
3
+ metadata.gz: 754bad405b747f3fb7e2ea5bfb46ca9e32262eb0f17c85d9804312da30adaa6f
4
+ data.tar.gz: 1a5643a5b733a4f536964e4ea33b5a38ee645cd752696d337a97cb824b72f442
5
5
  SHA512:
6
- metadata.gz: 9f4604d9ee1a6850d08968d5ccefec0a32e87a9a5176c92223c51bfadfbd13e268acbb4a3a0902120a209bc2b22095327ec441f3d01948743f7c96b522dc649e
7
- data.tar.gz: 86b33a3361e6b8b960d5cc8a3d4bbc21e440fb89a43a09c01308a9c48d8592f354e88637bc01102359bbec32c0c6ba7da82755bafaeab270556b110dbf4df21f
6
+ metadata.gz: f9f24f96751b877f6dd57da25502dbf7bdc23362e255ff78b677c18c3d51a3ffdc2b30ea101831fb2ce8a2b8e1cef665e968cd57c7394e0d897e8a8d2054eab3
7
+ data.tar.gz: 129b85d74bcb7c45552991b0d76af9f4955119a9a57fb44d56620970ef935f8a8df3667db1b5088c5836c1c0f8c72367c8d80a9876448e21019cf5a3026de66d
data/.travis.yml CHANGED
@@ -10,6 +10,7 @@ rvm:
10
10
  services:
11
11
  - mongodb
12
12
  env:
13
+ - "RAILS_VERSION=6.1.0"
13
14
  - "RAILS_VERSION=6.0.0"
14
15
  - "RAILS_VERSION=5.2.0"
15
16
  - "RAILS_VERSION=5.1.0"
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.2.2
2
+
3
+ * Support ActiveRecord 6.1
4
+
1
5
  # 0.2.1
2
6
 
3
7
  * Error's full_message with translation fixed thanks to [@marcelolx](https://github.com/trailblazer/reform-rails/pull/85)
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.include?('6.0')
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.include?('6.0')
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-Covid_19year Nick Sutterer
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
@@ -2,3 +2,4 @@ require "reform/form/orm"
2
2
  require "reform/form/active_model"
3
3
  require "reform/form/active_record"
4
4
  require "reform/form/active_model/model_reflections" # only load this in AR context as simple_form currently is bound to AR.
5
+ require "reform/form/active_model/result"
@@ -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
- text = @amv_errors.add(key, error_text)
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] |= text : @dotted_errors[key] = text
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
 
@@ -1,5 +1,5 @@
1
1
  module Reform
2
2
  module Rails
3
- VERSION = "0.2.1"
3
+ VERSION = "0.2.2"
4
4
  end
5
5
  end
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.1
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: 2020-11-16 00:00:00.000000000 Z
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.0.6
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: []