formwandler 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/formwandler/field_definition.rb +15 -10
- data/lib/formwandler/form.rb +6 -3
- data/lib/formwandler/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a45d189660c8aace9e7271c8d9dc110962a75954c538b8e0ffc29c882f0cde4
|
4
|
+
data.tar.gz: 85d1558cfd2507a7bbf57cb4c21f5c41f205df3230a49e408d4333e2c9fa40ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 136d046b2a96878ecdc22c39a8e1c4ff400a8e211d063397ad8e1d38aed2ddcf30e342e50c21292f6fbfbbefc809569be90fcd13c897d0c9bb5b05b1bdf280bc
|
7
|
+
data.tar.gz: f9fdf3e938ec7476755097233005a173c8b6ef68f4d8ec2ff24cd33edc1b300885f9a36392a09ba86de0516d38c7caa102bf2381cbd96b98886ad145906ca2f8
|
@@ -4,18 +4,12 @@ require_relative 'field_value_transformer'
|
|
4
4
|
|
5
5
|
module Formwandler
|
6
6
|
class FieldDefinition
|
7
|
-
attr_reader :name
|
7
|
+
attr_reader :name
|
8
|
+
attr_accessor :hidden, :disabled, :default, :delocalize, :model, :source, :options, :array
|
8
9
|
|
9
|
-
def initialize(name
|
10
|
+
def initialize(name)
|
10
11
|
@name = name
|
11
|
-
|
12
|
-
@disabled = disabled
|
13
|
-
@default = default
|
14
|
-
@delocalize = delocalize
|
15
|
-
@model = model
|
16
|
-
@source = source || name
|
17
|
-
@options = options
|
18
|
-
@array = array
|
12
|
+
set_defaults
|
19
13
|
end
|
20
14
|
|
21
15
|
def hide_option(name, value = true)
|
@@ -41,5 +35,16 @@ module Formwandler
|
|
41
35
|
private
|
42
36
|
|
43
37
|
attr_reader :value_transformer
|
38
|
+
|
39
|
+
def set_defaults
|
40
|
+
@hidden = false
|
41
|
+
@disabled = false
|
42
|
+
@default = nil
|
43
|
+
@delocalize = nil
|
44
|
+
@model = nil
|
45
|
+
@source = name
|
46
|
+
@options = nil
|
47
|
+
@array = false
|
48
|
+
end
|
44
49
|
end
|
45
50
|
end
|
data/lib/formwandler/form.rb
CHANGED
@@ -19,9 +19,12 @@ module Formwandler
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def field(name, opts = {}, &block)
|
22
|
-
field_definition = FieldDefinition.new(name
|
23
|
-
|
24
|
-
|
22
|
+
field_definition = field_definitions[name] ||= FieldDefinition.new(name)
|
23
|
+
opts.each do |key, value|
|
24
|
+
field_definition.public_send("#{key}=", value)
|
25
|
+
rescue NoMethodError
|
26
|
+
raise ArgumentError, "Invalid option #{key}"
|
27
|
+
end
|
25
28
|
field_definition.instance_exec(&block) if block_given?
|
26
29
|
|
27
30
|
attribute_accessor(name)
|
data/lib/formwandler/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: formwandler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Bilharz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-07-
|
11
|
+
date: 2018-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|