Class: DropboxApi::ResultBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/dropbox_api/result_builder.rb

Instance Method Summary collapse

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

#errorObject


11
12
13
# File 'lib/dropbox_api/result_builder.rb', line 11

def error
  @response_data["error"]
end

#error_summaryObject


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

Returns:

  • (Boolean)

15
16
17
# File 'lib/dropbox_api/result_builder.rb', line 15

def has_error?
  !error_summary.nil?
end

#success?Boolean

Returns:

  • (Boolean)

19
20
21
# File 'lib/dropbox_api/result_builder.rb', line 19

def success?
  !has_error?
end