formwandler 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/formwandler.rb +1 -0
- data/lib/formwandler/form_loader.rb +40 -0
- data/lib/formwandler/railtie.rb +11 -0
- data/lib/formwandler/version.rb +3 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9d6cfc5b1013e3204f17c536b1d487df7afe83e
|
4
|
+
data.tar.gz: e11b639f71da8ea99e114dfbc89dbaf1c334ba6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c1350ec9865df57a2f049d16d3bdc86817128ad8078636046198e038c59912d54b250899a7be1f3c07b33f7dc7a835dd448ef9ea41779a68566c227d350fa9a
|
7
|
+
data.tar.gz: adbfc536119e99a772827ed26718f342d4cd0deb836453db5e69d553f141cae62218d6402e8741d222bfab21514dc4cd8fa51b1ebe1033626a40cf73382a4125
|
data/lib/formwandler.rb
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Formwandler
|
4
|
+
module FormLoader
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
class_methods do
|
8
|
+
def load_form(opts = {})
|
9
|
+
before_action :_formwandler_load_form, opts
|
10
|
+
end
|
11
|
+
|
12
|
+
def skip_load_form(opts = {})
|
13
|
+
skip_before_action :_formwandler_load_form, opts
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def _formwandler_load_form
|
20
|
+
form_instance = form_class.new(models: {inferred_resource_name.to_sym => instance_variable_get("@#{inferred_resource_name}")}, controller: self)
|
21
|
+
instance_variable_set("@#{form_instance_name}", form_instance)
|
22
|
+
end
|
23
|
+
|
24
|
+
def form_class_name
|
25
|
+
"#{inferred_resource_name}_form".camelize
|
26
|
+
end
|
27
|
+
|
28
|
+
def form_class
|
29
|
+
form_class_name.constantize
|
30
|
+
end
|
31
|
+
|
32
|
+
def form_instance_name
|
33
|
+
form_class_name.underscore
|
34
|
+
end
|
35
|
+
|
36
|
+
def inferred_resource_name
|
37
|
+
controller_name.singularize
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: formwandler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Bilharz
|
@@ -119,6 +119,9 @@ files:
|
|
119
119
|
- lib/formwandler/field.rb
|
120
120
|
- lib/formwandler/field_definition.rb
|
121
121
|
- lib/formwandler/form.rb
|
122
|
+
- lib/formwandler/form_loader.rb
|
123
|
+
- lib/formwandler/railtie.rb
|
124
|
+
- lib/formwandler/version.rb
|
122
125
|
homepage: https://github.com/sbilharz/formwandler
|
123
126
|
licenses:
|
124
127
|
- MIT
|