Sha256: 02c55a32b2a67e010001e274d2c88f17733b8ddff91d2fc4fea0c0865e333647

Contents?: true

Size: 545 Bytes

Versions: 1

Compression:

Stored size: 545 Bytes

Contents

module JsonApiClient
  class ErrorCollector
    class Error
      include Helpers::DynamicAttributes

      def initialize(attrs = {})
        attrs = {
          title: attrs
        } if attrs.is_a?(String)
        self.attributes = attrs
      end
    end

    attr_reader :errors
    extend Forwardable
    def_delegators :errors, :length, :present?

    def initialize(error_data)
      @errors = Array(error_data).map do |datum|
        Error.new(datum)
      end
    end

    def full_messages
      errors.map(&:title)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
json_api_client-1.0.0.beta lib/json_api_client/error_collector.rb