Class: JSONAPI::OperationResults
- Inherits:
-
Object
- Object
- JSONAPI::OperationResults
- Defined in:
- lib/jsonapi/operation_results.rb
Instance Attribute Summary collapse
-
#links ⇒ Object
Returns the value of attribute links.
-
#meta ⇒ Object
Returns the value of attribute meta.
-
#results ⇒ Object
Returns the value of attribute results.
Instance Method Summary collapse
- #add_result(result) ⇒ Object
- #all_errors ⇒ Object
- #has_errors? ⇒ Boolean
-
#initialize ⇒ OperationResults
constructor
A new instance of OperationResults.
Constructor Details
#initialize ⇒ OperationResults
Returns a new instance of OperationResults.
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
#links ⇒ Object
Returns the value of attribute links.
5 6 7 |
# File 'lib/jsonapi/operation_results.rb', line 5 def links @links end |
#meta ⇒ Object
Returns the value of attribute meta.
4 5 6 |
# File 'lib/jsonapi/operation_results.rb', line 4 def @meta end |
#results ⇒ Object
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_errors ⇒ Object
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 |