Class: MyInfo::V3::Response

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

Overview

Simple response wrapper

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(success:, data:) ⇒ Response

Returns a new instance of Response.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/myinfo/v3/response.rb', line 9

def initialize(success:, data:)
  @success = success

  if data.is_a?(StandardError)
    @data = data.message
    @exception = true
  else
    @data = data
    @exception = false
  end
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



7
8
9
# File 'lib/myinfo/v3/response.rb', line 7

def data
  @data
end

Instance Method Details

#exception?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/myinfo/v3/response.rb', line 21

def exception?
  @exception
end

#success?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/myinfo/v3/response.rb', line 25

def success?
  @success
end

#to_sObject



29
30
31
# File 'lib/myinfo/v3/response.rb', line 29

def to_s
  data
end