Sha256: f22a793a8f2fb4aee239b8d89866e03da5caa17792a95363f7ddcd834df517a2

Contents?: true

Size: 509 Bytes

Versions: 16

Compression:

Stored size: 509 Bytes

Contents

module Virtus
  class Attribute

    # Attribute extension which raises CoercionError when coercion failed
    #
    module Strict

      # @see [Attribute#coerce]
      #
      # @raises [CoercionError] when coercer failed
      #
      # @api public
      def coerce(*)
        output = super

        if value_coerced?(output) || !required? && output.nil?
          output
        else
          raise CoercionError.new(output, self)
        end
      end

    end # Strict

  end # Attribute
end # Virtus

Version data entries

16 entries across 14 versions & 5 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/virtus-2.0.0/lib/virtus/attribute/strict.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/virtus-2.0.0/lib/virtus/attribute/strict.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/virtus-2.0.0/lib/virtus/attribute/strict.rb
virtus2-2.1.0 lib/virtus/attribute/strict.rb
virtus2-2.0.2 lib/virtus/attribute/strict.rb
virtus2-2.0.1 lib/virtus/attribute/strict.rb
virtus-2.0.0 lib/virtus/attribute/strict.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/virtus-1.0.5/lib/virtus/attribute/strict.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.4.0/gems/virtus-1.0.5/lib/virtus/attribute/strict.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/strict.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/virtus-1.0.5/lib/virtus/attribute/strict.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/virtus-1.0.5/lib/virtus/attribute/strict.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/strict.rb
virtus-1.0.5 lib/virtus/attribute/strict.rb
virtus-1.0.4 lib/virtus/attribute/strict.rb
virtus-1.0.3 lib/virtus/attribute/strict.rb