tramway-core 1.4.1 → 1.5
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2fb47273ad7fbf8b69de9fee539923577bd3f6306128825f6e1090ecbaf4dd64
|
|
4
|
+
data.tar.gz: 5704003c0d2aa42b1252a902165dddf278221d9023bfcf8973e0e2adc72b9ab6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1b4a09691cd871d95dd2d20a2bfb024d261519932e2b14f65bf564268e5d688a6b54d1b4d312c401248a2b69e4ff0c0fe10f4a02d9d564288be122a6d522b7d0
|
|
7
|
+
data.tar.gz: 67daeb423c28eb53e65eb7ffda0481855680a247b4d9394ea5df719787003e4a753148b71db9e2ce66c86ce26f407b963f04f7ccd3e110d9ef466ad5bbe8235c
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
module Tramway::Core
|
|
2
2
|
class ApplicationForm < ::Reform::Form
|
|
3
|
+
def initialize(object)
|
|
4
|
+
super(object).tap do
|
|
5
|
+
@@associations&.each do |association|
|
|
6
|
+
class_name = object.class.reflect_on_all_associations(:belongs_to).select do |a|
|
|
7
|
+
a.name == association.to_sym
|
|
8
|
+
end.first.options[:class_name].constantize
|
|
9
|
+
|
|
10
|
+
self.class.send(:define_method, "#{association}=") do |value|
|
|
11
|
+
super class_name.find value
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
3
17
|
def submit(params)
|
|
4
18
|
raise 'ApplicationForm::Params should not be nil'.inspect unless params
|
|
5
19
|
save if validate params
|
|
@@ -12,5 +26,13 @@ module Tramway::Core
|
|
|
12
26
|
def properties
|
|
13
27
|
@form_properties
|
|
14
28
|
end
|
|
29
|
+
|
|
30
|
+
class << self
|
|
31
|
+
def association(property)
|
|
32
|
+
properties property
|
|
33
|
+
@@associations ||= []
|
|
34
|
+
@@associations << property
|
|
35
|
+
end
|
|
36
|
+
end
|
|
15
37
|
end
|
|
16
38
|
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.
|
|
4
|
+
version: '1.5'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Pavel Kalashnikov
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-09-
|
|
11
|
+
date: 2018-09-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: reform-rails
|