All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gems.virtus-1.0.5.lib.virtus.attribute.strict.rb Maven / Gradle / Ivy

The newest version!
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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy