Class: JSONAPI::OperationResults

Inherits:
Object
  • Object
show all
Defined in:
lib/jsonapi/operation_results.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOperationResults


7
8
9
10
11
12
# File 'lib/jsonapi/operation_results.rb', line 7

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

Instance Attribute Details

Returns the value of attribute links


5
6
7
# File 'lib/jsonapi/operation_results.rb', line 5

def links
  @links
end

#metaObject

Returns the value of attribute meta


4
5
6
# File 'lib/jsonapi/operation_results.rb', line 4

def meta
  @meta
end

#resultsObject

Returns the value of attribute results


3
4
5
# File 'lib/jsonapi/operation_results.rb', line 3

def results
  @results
end

Instance Method Details

#add_result(result) ⇒ Object


14
15
16
17
# File 'lib/jsonapi/operation_results.rb', line 14

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

#all_errorsObject


23
24
25
26
27
28
29
30
31
32
33
# File 'lib/jsonapi/operation_results.rb', line 23

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

#has_errors?Boolean


19
20
21
# File 'lib/jsonapi/operation_results.rb', line 19

def has_errors?
  @has_errors
end