tramway-core 1.14.2.2 → 1.14.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/forms/tramway/core/application_form.rb +35 -3
- data/lib/tramway/core/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9820c9e325290379c9a5ad29f176d676cc704b89bfc1d860c44d18671c8da02
|
4
|
+
data.tar.gz: c1e52196bdbdf3fe0bf2b2c818ea29b42101daf482a901a6bf637895eb605dba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dad84b3585783d587299f0bf2d22e3d07dfef30f37c8f2a1a0c077d6defac10327495a6f836058a10a82711c6ab7c56b4be73ae2c43808b65e7621be99e3c5ea
|
7
|
+
data.tar.gz: 499cbb454235a26170f0dee382e38eb9eeaffb74eb1e4e7aac6c24f5763198eccdc3a92ff041bcd19f7d238f02e36ac0a220ecf64f60c906e03c9601429a57f0
|
@@ -34,8 +34,11 @@ module Tramway::Core
|
|
34
34
|
if params
|
35
35
|
if validate params
|
36
36
|
begin
|
37
|
-
save
|
37
|
+
save.tap do
|
38
|
+
#self.class.remove_validations_from_model!
|
39
|
+
end
|
38
40
|
rescue StandardError => e
|
41
|
+
#self.class.remove_validations_from_model!
|
39
42
|
error = Tramway::Error.new(plugin: :core, method: :submit, message: "Looks like you have method `#{e.name.to_s.gsub('=', '')}` in #{@@model_class}. You should rename it or rename property in #{self.class}")
|
40
43
|
raise error.message
|
41
44
|
end
|
@@ -47,9 +50,12 @@ module Tramway::Core
|
|
47
50
|
association_error = true
|
48
51
|
end
|
49
52
|
end
|
50
|
-
association_error && save
|
53
|
+
(association_error && save).tap do
|
54
|
+
#self.class.remove_validations_from_model!
|
55
|
+
end
|
51
56
|
end
|
52
57
|
else
|
58
|
+
#self.class.remove_validations_from_model!
|
53
59
|
error = Tramway::Error.new(plugin: :core, method: :submit, message: 'ApplicationForm::Params should not be nil')
|
54
60
|
raise error.message
|
55
61
|
end
|
@@ -149,13 +155,39 @@ module Tramway::Core
|
|
149
155
|
end
|
150
156
|
end
|
151
157
|
|
158
|
+
def model_class=(name)
|
159
|
+
@@model_class = name
|
160
|
+
end
|
161
|
+
|
152
162
|
def validation_group_class
|
153
163
|
ActiveModel
|
154
164
|
end
|
155
165
|
|
156
166
|
def validates(attribute, **options)
|
157
|
-
model_class
|
167
|
+
if !defined?(@@model_class) || @@model_class.nil?
|
168
|
+
error = Tramway::Error.new(plugin: :core, method: :validates, message: "You need to set `model_class` name while using validations. Just write `self.model_class = YOUR_MODEL_NAME` in the class area.")
|
169
|
+
raise error.message
|
170
|
+
end
|
171
|
+
@@model_class.validates attribute, **options
|
172
|
+
# @@validations ||= {}
|
173
|
+
# @@validations.deep_merge! attribute => options
|
158
174
|
end
|
175
|
+
|
176
|
+
# FIXME: Removes all validations in a field. We must implement own validations
|
177
|
+
|
178
|
+
#def remove_validations_from_model!
|
179
|
+
# return unless defined? @@validations
|
180
|
+
# @@validations&.each do |validation|
|
181
|
+
# @@model_class.class_eval do
|
182
|
+
# _validators.except validation[0]
|
183
|
+
#
|
184
|
+
# binding.pry
|
185
|
+
# _validate_callbacks.each do |callback|
|
186
|
+
# callback.raw_filter.attributes.delete validation[0]
|
187
|
+
# end
|
188
|
+
# end
|
189
|
+
# end
|
190
|
+
#end
|
159
191
|
end
|
160
192
|
end
|
161
193
|
end
|
data/lib/tramway/core/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tramway-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.14.2.
|
4
|
+
version: 1.14.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Kalashnikov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: audited
|