Method: Fission::Response#initialize

Defined in:
lib/fission/response.rb

#initialize(args = {}) ⇒ Response

Public: Initialize a Response object.

args - Hash of arguments:

:code    - Integer which denotes the code of the Response.  This is
           similar in concept to command line exit codes.  The
           convention is that 0 denotes success and any other value
           is unsuccessful (default: 1).
:message - String which denotes the message of the Response.  The
           convention is that this should only be used when the
           Response is unsuccessful (default: '').
:data    - Any valid ruby object.  This is used to convey any
           data that needs to be used by a caller.  The convention
           is that this should only be used when the Response is
           successful (default nil).

Examples

Response.new :code => 0, :data => [1, 2, 3, 4]

Response.new :code => 0, :data => true

Response.new :code => 5, :message => 'Something went wrong'

Returns a new Response instance.



37
38
39
40
41
# File 'lib/fission/response.rb', line 37

def initialize(args={})
  @code = args.fetch :code, 1
  @message = args.fetch :message, ''
  @data = args.fetch :data, nil
end