Sha256: 1a8f1e256117cd1116cdb9fbe2a8dcbfea2d057ba22e9d55eab11846dfde15c9

Contents?: true

Size: 430 Bytes

Versions: 14

Compression:

Stored size: 430 Bytes

Contents

module Virtus
  class Attribute

    # Attribute extension which nullifies blank attributes when coercion failed
    #
    module NullifyBlank

      # @see [Attribute#coerce]
      #
      # @api public
      def coerce(input)
        output = super

        if !value_coerced?(output) && input.to_s.empty?
          nil
        else
          output
        end
      end

    end # NullifyBlank

  end # Attribute
end # Virtus

Version data entries

14 entries across 12 versions & 5 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/virtus-2.0.0/lib/virtus/attribute/nullify_blank.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/virtus-2.0.0/lib/virtus/attribute/nullify_blank.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/virtus-2.0.0/lib/virtus/attribute/nullify_blank.rb
virtus2-2.1.0 lib/virtus/attribute/nullify_blank.rb
virtus2-2.0.2 lib/virtus/attribute/nullify_blank.rb
virtus2-2.0.1 lib/virtus/attribute/nullify_blank.rb
virtus-2.0.0 lib/virtus/attribute/nullify_blank.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/virtus-1.0.5/lib/virtus/attribute/nullify_blank.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.4.0/gems/virtus-1.0.5/lib/virtus/attribute/nullify_blank.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/virtus-1.0.5/lib/virtus/attribute/nullify_blank.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/virtus-1.0.5/lib/virtus/attribute/nullify_blank.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/virtus-1.0.5/lib/virtus/attribute/nullify_blank.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/virtus-1.0.5/lib/virtus/attribute/nullify_blank.rb
virtus-1.0.5 lib/virtus/attribute/nullify_blank.rb