formwandler 0.8.2 → 0.9.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.rb +1 -1
- data/lib/formwandler/field_definition.rb +4 -2
- data/lib/formwandler/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ffd1df3fd9bd73b09841ad5f2ea2179f4a9366fd11f65723948e0e43b217ff4
|
4
|
+
data.tar.gz: 5981014ba28b9dee2ecd47650d701ea8bc5d8de47c0094d96ed367e5d9eb332f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15d5c19992dda87e2e26c7cde5c38ce6040b4f9074f78639860f2c896ff04734f25dc0bf97d325ee49c3a52ac3de3b23f68a3d87dbd56b070e8066df5d23960e
|
7
|
+
data.tar.gz: dc25518420cd974025447a7bb824f09d99d583e006e5d8795e4ea860843243985577012afd2d8676b4b98a1010bda7b1794da44a8575043d4369198d9c468d6e
|
data/lib/formwandler/field.rb
CHANGED
@@ -67,7 +67,7 @@ module Formwandler
|
|
67
67
|
private
|
68
68
|
|
69
69
|
def transform_value(value, transformation)
|
70
|
-
return value if value.nil? || value == ''
|
70
|
+
return value if !field_definition.transform_blank && (value.nil? || value == '')
|
71
71
|
if transformation.respond_to?(:call)
|
72
72
|
form.instance_exec(value, &transformation)
|
73
73
|
else
|
@@ -4,11 +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, :transform_blank
|
8
8
|
attr_accessor :hidden, :disabled, :readonly, :default, :delocalize, :model, :model_class, :source, :options, :array
|
9
9
|
|
10
10
|
def initialize(name)
|
11
11
|
@name = name
|
12
|
+
@transform_blank = false
|
12
13
|
set_defaults
|
13
14
|
end
|
14
15
|
|
@@ -48,7 +49,8 @@ module Formwandler
|
|
48
49
|
@hidden_options ||= {}
|
49
50
|
end
|
50
51
|
|
51
|
-
def transform(&block)
|
52
|
+
def transform(allow_blank: false, &block)
|
53
|
+
@transform_blank = allow_blank
|
52
54
|
@value_transformer = FieldValueTransformer.new(&block)
|
53
55
|
end
|
54
56
|
|
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.9.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:
|
11
|
+
date: 2021-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -142,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
142
|
- !ruby/object:Gem::Version
|
143
143
|
version: '0'
|
144
144
|
requirements: []
|
145
|
-
rubygems_version: 3.1.
|
145
|
+
rubygems_version: 3.1.4
|
146
146
|
signing_key:
|
147
147
|
specification_version: 4
|
148
148
|
summary: Form objects for rails
|