action_form 0.6.4 → 0.6.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 +4 -4
- data/lib/action_form/base.rb +4 -2
- data/lib/action_form/elements_dsl.rb +3 -0
- data/lib/action_form/rails/base.rb +0 -13
- data/lib/action_form/schema_dsl.rb +2 -3
- data/lib/action_form/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 72382d4935502742cc4736c21c7964185e8fdb154972bc4ae38ae9497c18009d
|
|
4
|
+
data.tar.gz: a28f5cc2229551ce6a116721d8c34a4d134a2acc1bea9c1b081e633c20f60834
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6efb2e07f6de58b2d25af0e9dcaf3d0c779a7a72ea7d70acf0a840ceb70d74053902742b659369e99d7b723660e2bcac87784a9c17b1bfa3ad2f876d7e92d93b
|
|
7
|
+
data.tar.gz: 4fd0ede2b1ef5bc8a74f12ceefd75e4d5af245abe4a26cf60fa294320198904af6f2be66245beac5a96f45c7bb72f4f0409a2f352e6f068e0cdf3f558f338dd8
|
data/lib/action_form/base.rb
CHANGED
|
@@ -12,7 +12,7 @@ module ActionForm
|
|
|
12
12
|
attr_reader :elements_instances, :scope, :object, :html_options, :errors
|
|
13
13
|
|
|
14
14
|
class << self
|
|
15
|
-
attr_writer :elements, :scope
|
|
15
|
+
attr_writer :elements, :scope, :params_definition
|
|
16
16
|
|
|
17
17
|
def subform_class
|
|
18
18
|
ActionForm::Subform
|
|
@@ -28,6 +28,8 @@ module ActionForm
|
|
|
28
28
|
super
|
|
29
29
|
subclass.elements = elements.dup
|
|
30
30
|
subclass.scope = scope.dup
|
|
31
|
+
subclass.params_definition = Class.new(params_definition)
|
|
32
|
+
subclass.params_definition.form_class = subclass
|
|
31
33
|
end
|
|
32
34
|
end
|
|
33
35
|
|
|
@@ -35,7 +37,7 @@ module ActionForm
|
|
|
35
37
|
super()
|
|
36
38
|
@object = object
|
|
37
39
|
@scope ||= scope
|
|
38
|
-
@params =
|
|
40
|
+
@params = params
|
|
39
41
|
@html_options = html_options
|
|
40
42
|
@elements_instances = []
|
|
41
43
|
@owner = owner
|
|
@@ -24,6 +24,7 @@ module ActionForm
|
|
|
24
24
|
|
|
25
25
|
# TODO: add support for outputless elements
|
|
26
26
|
def element(name, &block)
|
|
27
|
+
@params_definition = nil
|
|
27
28
|
elements[name] = Class.new(ActionForm::Element)
|
|
28
29
|
elements[name].class_eval(&block)
|
|
29
30
|
define_singleton_method(:"#{name}_element") do |klass = nil, &block|
|
|
@@ -32,6 +33,7 @@ module ActionForm
|
|
|
32
33
|
end
|
|
33
34
|
|
|
34
35
|
def many(name, default: nil, &block)
|
|
36
|
+
@params_definition = nil
|
|
35
37
|
subform_definition = Class.new(ActionForm::SubformsCollection)
|
|
36
38
|
subform_definition.host_class = self
|
|
37
39
|
subform_definition.class_eval(&block) if block
|
|
@@ -43,6 +45,7 @@ module ActionForm
|
|
|
43
45
|
end
|
|
44
46
|
|
|
45
47
|
def subform(name, default: nil, &block)
|
|
48
|
+
@params_definition = nil
|
|
46
49
|
elements[name] = Class.new(subform_class)
|
|
47
50
|
elements[name].class_eval(&block)
|
|
48
51
|
elements[name].default = default if default
|
|
@@ -31,19 +31,6 @@ module ActionForm
|
|
|
31
31
|
@scope = model.model_name.param_key.to_sym
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
def params_definition(scope: self.scope)
|
|
35
|
-
return super unless scope
|
|
36
|
-
|
|
37
|
-
@params_definitions ||= Hash.new do |h, key|
|
|
38
|
-
h[key] = begin
|
|
39
|
-
klass = super
|
|
40
|
-
Class.new(params_class) { has scope, klass }
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
@params_definitions[scope].form_class = self
|
|
44
|
-
@params_definitions[scope]
|
|
45
|
-
end
|
|
46
|
-
|
|
47
34
|
def many(name, default: nil, &block)
|
|
48
35
|
super
|
|
49
36
|
elements[name].subform_definition.add_primary_key_element
|
|
@@ -13,13 +13,12 @@ module ActionForm
|
|
|
13
13
|
ActionForm::Params
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
def params_definition
|
|
16
|
+
def params_definition
|
|
17
17
|
@params_definition ||= create_params_definition
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def params(&block)
|
|
21
|
-
@params_definition =
|
|
22
|
-
@params_definition.class_eval(&block) if block
|
|
21
|
+
@params_definition = Class.new(params_definition, &block) if block
|
|
23
22
|
end
|
|
24
23
|
|
|
25
24
|
def create_params_definition # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
data/lib/action_form/version.rb
CHANGED