Sha256: db4dec563599671aeb09d4e5f92226faadfe9f1ef6e8c5da42b0a2f9bd5ce6fe

Contents?: true

Size: 453 Bytes

Versions: 5

Compression:

Stored size: 453 Bytes

Contents

module Trestle
  class DebugErrors
    def initialize(errors)
      @errors = errors
    end

    def any?
      @errors.any?
    end

    def each
      if defined?(ActiveModel::Error)
        # Rails 6.1 introduces a unified Error class
        @errors.each do |error|
          yield error.attribute, error.message
        end
      else
        @errors.each do |error, message|
          yield error, message
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
trestle-0.10.1 lib/trestle/debug_errors.rb
trestle-0.10.0 lib/trestle/debug_errors.rb
trestle-0.10.0.pre2 lib/trestle/debug_errors.rb
trestle-0.10.0.pre lib/trestle/debug_errors.rb
trestle-0.9.8 lib/trestle/debug_errors.rb