Sha256: 6ff60a36d704431f41c3fff34348bef8d7bf1db49e8acc3387df677c5afd4431

Contents?: true

Size: 557 Bytes

Versions: 5

Compression:

Stored size: 557 Bytes

Contents

module SimpleJsonapi
  module Errors
    class ActiveModelError
      def self.from_errors(errors, pointer_mapping = {})
        errors.keys.flat_map do |attribute|
          errors.full_messages_for(attribute).map do |message|
            new(attribute, message, pointer_mapping[attribute])
          end
        end
      end

      attr_reader :attribute, :message, :pointer

      def initialize(attribute, message, pointer)
        @attribute = attribute.to_s
        @message = message.to_s
        @pointer = pointer.to_s
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
simple_jsonapi_rails-1.3.0 lib/simple_jsonapi/errors/active_model_error.rb
simple_jsonapi_rails-1.2.0 lib/simple_jsonapi/errors/active_model_error.rb
simple_jsonapi_rails-1.1.1 lib/simple_jsonapi/errors/active_model_error.rb
simple_jsonapi_rails-1.1.0 lib/simple_jsonapi/errors/active_model_error.rb
simple_jsonapi_rails-1.0.0 lib/simple_jsonapi/errors/active_model_error.rb