Sha256: 41749acf22b51d5ed1661709b0e50944b2a7fc87eee6948426c2bd1ae57b19ae
Contents?: true
Size: 787 Bytes
Versions: 43
Compression:
Stored size: 787 Bytes
Contents
# frozen_string_literal: true module FmRest module Spyke # ActiveModel 4 doesn't include a ValidationError class, which we want to # raise when model.validate! fails. # # In order to break the least amount of code that uses AM5+, while still # supporting AM4 we use this proxy class that inherits from # AM::ValidationError if it's there, or reimplements it otherwise if defined?(::ActiveModel::ValidationError) class ValidationError < ::ActiveModel::ValidationError; end else class ValidationError < StandardError attr_reader :model def initialize(model) @model = model errors = @model.errors.full_messages.join(", ") super("Invalid model: #{errors}") end end end end end
Version data entries
43 entries across 43 versions & 2 rubygems