Class: ServiceRecord::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/service_record/response.rb

Overview

Response to be returned by a service when it finishes

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result, errors) ⇒ Response

Returns a new instance of Response.



8
9
10
11
# File 'lib/service_record/response.rb', line 8

def initialize(result, errors)
  @result = result
  @errors = errors
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



6
7
8
# File 'lib/service_record/response.rb', line 6

def errors
  @errors
end

#resultObject (readonly)

Returns the value of attribute result.



6
7
8
# File 'lib/service_record/response.rb', line 6

def result
  @result
end

Instance Method Details

#failure?Boolean

Checks for errors. Returns false if no errors are found, true otherwise.

Returns:

  • (Boolean)


19
20
21
# File 'lib/service_record/response.rb', line 19

def failure?
  !success?
end

#success?Boolean

Checks for errors. Returns true if no errors are found, false otherwise.

Returns:

  • (Boolean)


14
15
16
# File 'lib/service_record/response.rb', line 14

def success?
  errors.empty?
end