Class: Amiando::Boolean
- Inherits:
-
Object
- Object
- Amiando::Boolean
- Includes:
- Autorun
- Defined in:
- lib/amiando/boolean.rb
Overview
This object is intended to be used when an api will return a boolean response, but due to the delayed nature of doing requests in parallel, can’t be initialized from the beginning.
After the object is populated, you can ask the result with the result method.
Instance Attribute Summary collapse
-
#request ⇒ Object
Returns the value of attribute request.
-
#response ⇒ Object
Returns the value of attribute response.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#success ⇒ Object
readonly
Returns the value of attribute success.
Instance Method Summary collapse
-
#initialize(response_attribute) ⇒ Boolean
constructor
A new instance of Boolean.
- #populate(response_body) ⇒ Object
Methods included from Autorun
Constructor Details
#initialize(response_attribute) ⇒ Boolean
Returns a new instance of Boolean.
18 19 20 |
# File 'lib/amiando/boolean.rb', line 18 def initialize(response_attribute) @response_attribute = response_attribute.to_s end |
Instance Attribute Details
#request ⇒ Object
Returns the value of attribute request.
13 14 15 |
# File 'lib/amiando/boolean.rb', line 13 def request @request end |
#response ⇒ Object
Returns the value of attribute response.
13 14 15 |
# File 'lib/amiando/boolean.rb', line 13 def response @response end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
14 15 16 |
# File 'lib/amiando/boolean.rb', line 14 def result @result end |
#success ⇒ Object (readonly)
Returns the value of attribute success.
14 15 16 |
# File 'lib/amiando/boolean.rb', line 14 def success @success end |
Instance Method Details
#populate(response_body) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/amiando/boolean.rb', line 22 def populate(response_body) if response_body.key?(@response_attribute) @result = response_body[@response_attribute] @success = response_body['success'] else raise Error::NotInitialized.new("The response doesn't have the expected attribute") end end |