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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c58985c9314b2ee1dbeb4372f7c0554eb16322c27767daaf227ae6be46b8b61e
4
- data.tar.gz: cc39146f7953edc67dc131ec87e48d54b6631882f2457b565744ebabb602ab92
3
+ metadata.gz: 9ffd1df3fd9bd73b09841ad5f2ea2179f4a9366fd11f65723948e0e43b217ff4
4
+ data.tar.gz: 5981014ba28b9dee2ecd47650d701ea8bc5d8de47c0094d96ed367e5d9eb332f
5
5
  SHA512:
6
- metadata.gz: 55eeb2ca00dcf309f9eaa60a57326fb5feb3f684a5ddf2fcaf889e551b03048f60863570a97f4fa6b886b13bc9a27b01839d1ef751506158a010569d6f7b4cf4
7
- data.tar.gz: 593380319ef6ac9e31a74ac204aa0ac9f88b402ff077a23caa0b67c3a4ae0d526814f6c18b15057953858c5db0fc4bcecd3434c4f0bec201359a6b09b67ac723
6
+ metadata.gz: 15d5c19992dda87e2e26c7cde5c38ce6040b4f9074f78639860f2c896ff04734f25dc0bf97d325ee49c3a52ac3de3b23f68a3d87dbd56b070e8066df5d23960e
7
+ data.tar.gz: dc25518420cd974025447a7bb824f09d99d583e006e5d8795e4ea860843243985577012afd2d8676b4b98a1010bda7b1794da44a8575043d4369198d9c468d6e
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module Formwandler
2
- VERSION = '0.8.2'
2
+ VERSION = '0.9.0'
3
3
  end
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.8.2
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: 2020-09-03 00:00:00.000000000 Z
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.2
145
+ rubygems_version: 3.1.4
146
146
  signing_key:
147
147
  specification_version: 4
148
148
  summary: Form objects for rails