Class: Bigbank::Client::Result

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

Direct Known Subclasses

Application::ApplicationResult

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Result

Returns a new instance of Result.



6
7
8
# File 'lib/bigbank/client/result.rb', line 6

def initialize(response)
  @response = response
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object

Allows us to work directly with the result in a more natural way e.g. use enumerator methods, nil check etc.



26
27
28
# File 'lib/bigbank/client/result.rb', line 26

def method_missing(name, *args, &block)
  response.body.send(name, *args, &block)
end

Instance Attribute Details

#responseObject

Returns the value of attribute response.



4
5
6
# File 'lib/bigbank/client/result.rb', line 4

def response
  @response
end

Instance Method Details

#errors?Boolean

Public: result is a failure

return @boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/bigbank/client/result.rb', line 20

def errors?
  !success?
end

#success?Boolean

Public: result is a success

return @boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/bigbank/client/result.rb', line 13

def success?
  response.status == 200
end