Class: DropboxApi::Metadata::ThumbnailBatchResultEntry

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

Overview

This class is used as an adapter so we can create an object of the pertinent class when we need to infer the type from the data.

This same pattern is used in DropboxApi::Metadata::Resource

So this could initalize an object of either ThumbnailBatchResultData or ThumbnailError.

Class Method Summary collapse

Class Method Details

.new(data) ⇒ Object


11
12
13
14
15
16
17
18
19
20
# File 'lib/dropbox_api/metadata/thumbnail_batch_result_entry.rb', line 11

def new(data)
  case data[".tag"].to_sym
  when :success
    DropboxApi::Metadata::ThumbnailBatchResultData.new(data)
  when :failure
    DropboxApi::Errors::ThumbnailError.build("Thumbnail generation failed", data["failure"])
  else
    raise NotImplementedError, "Unknown result type: #{data[".tag"]}"
  end
end