Sha256: c434b12e9c4e78e0334b52b968dc6144f57d8cea0e1f01dd951b6d6f7626cd58

Contents?: true

Size: 398 Bytes

Versions: 7

Compression:

Stored size: 398 Bytes

Contents

module Rasti
  class Form
    module Castable

      def cast(value)
        if valid? value
          transform! value
        else
          raise CastError.new self, value
        end
      end

      private

      def transform!(value)
        transform value
      rescue ValidationError => ex
        raise ex
      rescue
        raise CastError.new self, value
      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rasti-form-1.1.1 lib/rasti/form/castable.rb
rasti-form-1.1.0 lib/rasti/form/castable.rb
rasti-form-1.0.3 lib/rasti/form/castable.rb
rasti-form-1.0.2 lib/rasti/form/castable.rb
rasti-form-1.0.1 lib/rasti/form/castable.rb
rasti-form-1.0.0 lib/rasti/form/castable.rb
rasti-form-0.1.0 lib/rasti/form/castable.rb