Class: RubyAem::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_aem/result.rb

Overview

Result represents the result of a client call.

It has 3 statuses: success, warning, and failure. A success indicates that the client call was completed successfully. A failure indicates that the client call was completed but it failed with error. A warning indicates that the client call was completed but with warnings.

Result message is stored in message attribute.

Some client calls respond with data payload, which is stored in data attribute.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status, message) ⇒ Object

Initialise a result.

Parameters:

  • status

    the result status: success, warning, or failure

  • message

    the result message



38
39
40
41
# File 'lib/ruby_aem/result.rb', line 38

def initialize(status, message)
  @status = status
  @message = message
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



31
32
33
# File 'lib/ruby_aem/result.rb', line 31

def data
  @data
end

#messageObject (readonly)

Returns the value of attribute message.



30
31
32
# File 'lib/ruby_aem/result.rb', line 30

def message
  @message
end

Instance Method Details

#is_failure?Boolean

Check whether the client call failed.

Returns:

  • (Boolean)

    true when the status is failure



61
62
63
# File 'lib/ruby_aem/result.rb', line 61

def is_failure?
  return @status == 'failure'
end

#is_success?Boolean

Check whether the client call was successful.

Returns:

  • (Boolean)

    true when the status is success



46
47
48
# File 'lib/ruby_aem/result.rb', line 46

def is_success?
  return @status == 'success'
end

#is_warning?Boolean

Check whether the client call was completed with warnings.

Returns:

  • (Boolean)

    true when the status is warning



54
55
56
# File 'lib/ruby_aem/result.rb', line 54

def is_warning?
  return @status == 'warning'
end