Module: Shrine::Plugins::DerivationEndpoint::FileMethods

Defined in:
lib/shrine/plugins/derivation_endpoint.rb

Instance Method Summary collapse

Instance Method Details

#derivation(name, *args, **options) ⇒ Object

Returns a Shrine::Derivation object created from the provided arguments. This object offers additional methods for operating with derivatives on a lower level.



109
110
111
112
113
114
115
116
# File 'lib/shrine/plugins/derivation_endpoint.rb', line 109

def derivation(name, *args, **options)
  Shrine::Derivation.new(
    name:    name,
    args:    args,
    source:  self,
    options: options,
  )
end

#derivation_response(name, *args, env:, **options) ⇒ Object

Calls the specified derivation with the receiver as the source file, returning a Rack response triple. The derivation endpoint ultimately calls this method.



102
103
104
# File 'lib/shrine/plugins/derivation_endpoint.rb', line 102

def derivation_response(name, *args, env:, **options)
  derivation(name, *args, **options).response(env)
end

#derivation_url(name, *args, **options) ⇒ Object

Generates a URL to a derivation with the receiver as the source file. Any arguments provided will be included in the URL and passed to the derivation block. Accepts additional URL options.



95
96
97
# File 'lib/shrine/plugins/derivation_endpoint.rb', line 95

def derivation_url(name, *args, **options)
  derivation(name, *args).url(**options)
end