tramway-core 1.14.1 → 1.14.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: e06dd12520cbfb6d2bee1e3413a77981c47ec5e5e378824cfec90552c050cd52
4
- data.tar.gz: '041449acadc36a3cc9fd48899d8cbe681cb2ff320f982d0eae6960fc951b61dd'
3
+ metadata.gz: 18a93e1530863c7ddb15e6adb573d5ea06aae29357eabdf06ed433dc9e170cc6
4
+ data.tar.gz: 8066187cef4863fa4f7a830d90a90ed78afffb2aa29fef32760b5037d07da38c
5
5
  SHA512:
6
- metadata.gz: 52ed13303d8a9e93abc1a984660bb70a9be2a89a19de430263ad8fc66a3395a65aa0b0ff345d4a6753a3d583db63891f44770a7a5dd6fdcdaa4e92ab949054d9
7
- data.tar.gz: 96627ac531b0bba886bbad49a455252531d51db9128a0173b389b7a4d14338b9d422cbca040c7696941f93555bbd2098a35a5e68f5bbc40885f1af8da1dd4d14
6
+ metadata.gz: d05a35d45517d87b4d25908edc824e07aedaea45ec617c7b296131104cb6d9435e3b1fcf60ba38e1594cc9ac570bc913910d797c74614d2916e72f60f45b43c0
7
+ data.tar.gz: 8554ecb444b5c84a819ee6fc4a8cd28bca1c250a39eb4113481bb788180bd1e6636d0e309e9542be054568f45d738e8d5cc4ad09d01320f896bfa425c8d211a7
@@ -32,7 +32,23 @@ module Tramway::Core
32
32
 
33
33
  def submit(params)
34
34
  if params
35
- save if validate params
35
+ if validate params
36
+ begin
37
+ save
38
+ rescue StandardError => e
39
+ 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
+ raise error.message
41
+ end
42
+ else
43
+ association_error = false
44
+ @@associations.each do |association|
45
+ if errors.details[association] == [{ error: :blank }]
46
+ model.send("#{association}=", send(association))
47
+ association_error = true
48
+ end
49
+ end
50
+ association_error && save
51
+ end
36
52
  else
37
53
  error = Tramway::Error.new(plugin: :core, method: :submit, message: 'ApplicationForm::Params should not be nil')
38
54
  raise error.message
@@ -47,9 +63,20 @@ module Tramway::Core
47
63
  @form_properties = args
48
64
  end
49
65
 
66
+ def form_properties_additional(**args)
67
+ @form_properties_additional = args
68
+ end
69
+
50
70
  def properties
51
71
  return @form_properties if @form_properties
52
- @form_properties = YAML.load_file(Rails.root.join('app', 'forms', "#{self.class.name.underscore}.yml")).deep_symbolize_keys
72
+ yaml_config_file_path = Rails.root.join('app', 'forms', "#{self.class.name.underscore}.yml")
73
+ if File.exist? yaml_config_file_path
74
+ @form_properties = YAML.load_file(yaml_config_file_path).deep_symbolize_keys
75
+ @form_properties.deep_merge! @form_properties_additional if @form_properties_additional
76
+ @form_properties
77
+ else
78
+ []
79
+ end
53
80
  end
54
81
 
55
82
  def build_errors; end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tramway
4
4
  module Core
5
- VERSION = '1.14.1'
5
+ VERSION = '1.14.2.2'
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.1
4
+ version: 1.14.2.2
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-07 00:00:00.000000000 Z
11
+ date: 2019-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: audited