Sha256: 5f36047d87e92f4633f98b34e35a9ef0f9d0b27de2f5264a3e182c14e4248000

Contents?: true

Size: 668 Bytes

Versions: 44

Compression:

Stored size: 668 Bytes

Contents

module JSONAPI
  class OperationResults
    attr_accessor :results
    attr_accessor :meta
    attr_accessor :links

    def initialize
      @results = []
      @has_errors = false
      @meta = {}
      @links = {}
    end

    def add_result(result)
      @has_errors = true if result.is_a?(JSONAPI::ErrorsOperationResult)
      @results.push(result)
    end

    def has_errors?
      @has_errors
    end

    def all_errors
      errors = []
      if @has_errors
        @results.each do |result|
          if result.is_a?(JSONAPI::ErrorsOperationResult)
            errors.concat(result.errors)
          end
        end
      end
      errors
    end
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
jsonapi-resources-0.4.4 lib/jsonapi/operation_results.rb
jsonapi-resources-0.4.3 lib/jsonapi/operation_results.rb
jsonapi-resources-0.4.2 lib/jsonapi/operation_results.rb
jsonapi-resources-0.4.1 lib/jsonapi/operation_results.rb