Methods
Public Class
Public Instance
Classes and Modules
- Shrine::Derivation::Command
- Shrine::Derivation::Delete
- Shrine::Derivation::Generate
- Shrine::Derivation::NotFound
- Shrine::Derivation::Opened
- Shrine::Derivation::Processed
- Shrine::Derivation::Response
- Shrine::Derivation::Retrieve
- Shrine::Derivation::SourceNotFound
- Shrine::Derivation::Upload
- Shrine::Derivation::Url
Public Class methods
new(name:, args:, source:, options:)
[show source]
# File lib/shrine/plugins/derivation_endpoint.rb 124 def initialize(name:, args:, source:, options:) 125 @name = name.to_sym 126 @args = args 127 @source = source 128 @options = options 129 end
option(name, default: nil, result: nil)
[show source]
# File lib/shrine/plugins/derivation_endpoint.rb 186 def self.option(name, default: nil, result: nil) 187 options[name] = { default: default, result: result } 188 end
options()
[show source]
# File lib/shrine/plugins/derivation_endpoint.rb 182 def self.options 183 @options ||= {} 184 end
Public Instance methods
delete()
Deletes the derivation result from the storage.
[show source]
# File lib/shrine/plugins/derivation_endpoint.rb 178 def delete 179 Derivation::Delete.new(self).call 180 end
generate(file = nil)
Calls the derivation block and returns the direct result.
[show source]
# File lib/shrine/plugins/derivation_endpoint.rb 155 def generate(file = nil) 156 Derivation::Generate.new(self).call(file) 157 end
opened()
Returns opened Shrine::UploadedFile
object pointing to the uploaded derivative if it exists.
[show source]
# File lib/shrine/plugins/derivation_endpoint.rb 173 def opened 174 Derivation::Opened.new(self).call 175 end
option(name)
Retrieves the value of a derivation option.
-
If specified as a raw value, returns that value
-
If specified as a block, evaluates that it and returns the result
-
If unspecified, returns the default value
[show source]
# File lib/shrine/plugins/derivation_endpoint.rb 216 def option(name) 217 option_definition = self.class.options.fetch(name) 218 219 value = options.fetch(name) { shrine_class.derivation_options[name] } 220 value = instance_exec(&value) if value.is_a?(Proc) && value.arity == 0 221 222 if value.nil? 223 default = option_definition[:default] 224 value = instance_exec(&default) if default 225 end 226 227 result = option_definition[:result] 228 value = instance_exec(value, &result) if result 229 230 value 231 end
processed()
Returns the derivation result as a File/Tempfile or a Shrine::UploadedFile
object.
[show source]
# File lib/shrine/plugins/derivation_endpoint.rb 150 def processed 151 Derivation::Processed.new(self).call 152 end
response(env)
Returns the derivation result in form of a Rack response triple.
[show source]
# File lib/shrine/plugins/derivation_endpoint.rb 144 def response(env) 145 Derivation::Response.new(self).call(env) 146 end
retrieve()
Returns a Shrine::UploadedFile
object pointing to the uploaded derivative if it exists.
[show source]
# File lib/shrine/plugins/derivation_endpoint.rb 167 def retrieve 168 Derivation::Retrieve.new(self).call 169 end
shrine_class()
[show source]
# File lib/shrine/plugins/derivation_endpoint.rb 233 def shrine_class 234 source.shrine_class 235 end
upload(file = nil, **options)
Uploads the derivation result to a dedicated destination on the specified Shrine
storage.
[show source]
# File lib/shrine/plugins/derivation_endpoint.rb 161 def upload(file = nil, **options) 162 Derivation::Upload.new(self).call(file, **options) 163 end
url(**options)
Returns an URL to the derivation.
[show source]
# File lib/shrine/plugins/derivation_endpoint.rb 132 def url(**options) 133 Derivation::Url.new(self).call( 134 host: option(:host), 135 prefix: option(:prefix), 136 expires_in: option(:expires_in), 137 version: option(:version), 138 metadata: option(:metadata), 139 **options, 140 ) 141 end