Class: Bigbank::Client::Result
- Inherits:
-
Object
- Object
- Bigbank::Client::Result
- Defined in:
- lib/bigbank/client/result.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
-
#errors? ⇒ Boolean
Public: result is a failure.
-
#initialize(response) ⇒ Result
constructor
A new instance of Result.
-
#method_missing(name, *args, &block) ⇒ Object
Allows us to work directly with the result in a more natural way e.g.
-
#success? ⇒ Boolean
Public: result is a success.
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
#response ⇒ Object
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
20 21 22 |
# File 'lib/bigbank/client/result.rb', line 20 def errors? !success? end |
#success? ⇒ Boolean
Public: result is a success
return @boolean
13 14 15 |
# File 'lib/bigbank/client/result.rb', line 13 def success? response.status == 200 end |