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.
4 5 6 |
# File 'lib/dropbox_api/result_builder.rb', line 4 def initialize(response_data) @response_data = response_data end |
Instance Method Details
#build(result_class) ⇒ Object
24 25 26 |
# File 'lib/dropbox_api/result_builder.rb', line 24 def build(result_class) result_class.new(@response_data) end |
#build_error(error_type) ⇒ Object
28 29 30 |
# File 'lib/dropbox_api/result_builder.rb', line 28 def build_error(error_type) error_type.build(error_summary, error) end |
#error ⇒ Object
12 13 14 |
# File 'lib/dropbox_api/result_builder.rb', line 12 def error @response_data['error'] end |
#error_summary ⇒ Object
8 9 10 |
# File 'lib/dropbox_api/result_builder.rb', line 8 def error_summary @response_data['error_summary'] if @response_data.is_a? Hash end |
#has_error? ⇒ Boolean
16 17 18 |
# File 'lib/dropbox_api/result_builder.rb', line 16 def has_error? !error_summary.nil? end |
#success? ⇒ Boolean
20 21 22 |
# File 'lib/dropbox_api/result_builder.rb', line 20 def success? !has_error? end |