Class: Shrine::Storage::GoogleCloudStorage::ProcIO

Inherits:
Object
  • Object
show all
Defined in:
lib/shrine/storage/google_cloud_storage.rb

Overview

This class provides a writable IO wrapper around a proc object, with #write simply calling the proc, which we can pass in as the destination IO for download.

Instance Method Summary collapse

Constructor Details

#initialize(&proc) ⇒ ProcIO

Returns a new instance of ProcIO.



199
200
201
# File 'lib/shrine/storage/google_cloud_storage.rb', line 199

def initialize(&proc)
  @proc = proc
end

Instance Method Details

#flushObject

TODO: Remove this once google/google-api-ruby-client#638 is merged.



209
210
211
# File 'lib/shrine/storage/google_cloud_storage.rb', line 209

def flush
  # google-api-client calls this method
end

#write(data) ⇒ Object



203
204
205
206
# File 'lib/shrine/storage/google_cloud_storage.rb', line 203

def write(data)
  @proc.call(data)
  data.bytesize # match return value of other IO objects
end