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.


104
105
106
107
108
109
110
111
# File 'lib/shrine/plugins/derivation_endpoint.rb', line 104

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.


97
98
99
# File 'lib/shrine/plugins/derivation_endpoint.rb', line 97

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.


90
91
92
# File 'lib/shrine/plugins/derivation_endpoint.rb', line 90

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