tramway-core 1.14.2.2 → 1.14.2.3

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: 18a93e1530863c7ddb15e6adb573d5ea06aae29357eabdf06ed433dc9e170cc6
4
- data.tar.gz: 8066187cef4863fa4f7a830d90a90ed78afffb2aa29fef32760b5037d07da38c
3
+ metadata.gz: c9820c9e325290379c9a5ad29f176d676cc704b89bfc1d860c44d18671c8da02
4
+ data.tar.gz: c1e52196bdbdf3fe0bf2b2c818ea29b42101daf482a901a6bf637895eb605dba
5
5
  SHA512:
6
- metadata.gz: d05a35d45517d87b4d25908edc824e07aedaea45ec617c7b296131104cb6d9435e3b1fcf60ba38e1594cc9ac570bc913910d797c74614d2916e72f60f45b43c0
7
- data.tar.gz: 8554ecb444b5c84a819ee6fc4a8cd28bca1c250a39eb4113481bb788180bd1e6636d0e309e9542be054568f45d738e8d5cc4ad09d01320f896bfa425c8d211a7
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.validates attribute, **options
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tramway
4
4
  module Core
5
- VERSION = '1.14.2.2'
5
+ VERSION = '1.14.2.3'
6
6
  end
7
7
  end
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.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-13 00:00:00.000000000 Z
11
+ date: 2019-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: audited