Class: Shrine::Derivation::Upload

Inherits:
Command
  • Object
show all
Defined in:
lib/shrine/plugins/derivation_endpoint.rb

Instance Attribute Summary

Attributes inherited from Command

#derivation

Instance Method Summary collapse

Methods inherited from Command

delegate, #initialize

Constructor Details

This class inherits a constructor from Shrine::Derivation::Command

Instance Method Details

#call(derivative = nil, **options) ⇒ Object

Uploads the derivation result to the dedicated location on the storage. If a file object is given, uploads that to the storage, otherwise calls the derivation block and uploads the result.



644
645
646
647
648
649
650
# File 'lib/shrine/plugins/derivation_endpoint.rb', line 644

def call(derivative = nil, **options)
  if derivative
    upload(derivative, **options)
  else
    upload(derivation.generate, delete: true, **options)
  end
end