Class: DropboxApi::ResultBuilder
- Inherits:
-
Object
- Object
- DropboxApi::ResultBuilder
- Defined in:
- lib/dropbox_api/result_builder.rb
Instance Method Summary collapse
- #build(result_class) ⇒ Object
- #build_error(error_type) ⇒ Object
- #error ⇒ Object
- #error_summary ⇒ Object
- #has_error? ⇒ Boolean
-
#initialize(response_data) ⇒ ResultBuilder
constructor
A new instance of ResultBuilder.
- #success? ⇒ Boolean
Constructor Details
#initialize(response_data) ⇒ ResultBuilder
Returns a new instance of ResultBuilder.
3 4 5 |
# File 'lib/dropbox_api/result_builder.rb', line 3 def initialize(response_data) @response_data = response_data end |
Instance Method Details
#build(result_class) ⇒ Object
23 24 25 |
# File 'lib/dropbox_api/result_builder.rb', line 23 def build(result_class) result_class.new(@response_data) end |
#build_error(error_type) ⇒ Object
27 28 29 |
# File 'lib/dropbox_api/result_builder.rb', line 27 def build_error(error_type) error_type.build(error_summary, error) end |
#error ⇒ Object
11 12 13 |
# File 'lib/dropbox_api/result_builder.rb', line 11 def error @response_data["error"] end |
#error_summary ⇒ Object
7 8 9 |
# File 'lib/dropbox_api/result_builder.rb', line 7 def error_summary @response_data["error_summary"] if @response_data.is_a? Hash end |
#has_error? ⇒ Boolean
15 16 17 |
# File 'lib/dropbox_api/result_builder.rb', line 15 def has_error? !error_summary.nil? end |
#success? ⇒ Boolean
19 20 21 |
# File 'lib/dropbox_api/result_builder.rb', line 19 def success? !has_error? end |