Sha256: f97b5856cffe4fe6343c0959e3ec3e5e57698ebe48ad74d000772bd258413abe
Contents?: true
Size: 1.27 KB
Versions: 11
Compression:
Stored size: 1.27 KB
Contents
module Scrivito class BinaryRouting < Struct.new(:request, :scrivito_engine) def binary_url(binary) binary_url_from_cache(binary) || binary_redirect_url(binary) end def binary_obj_url(obj, binary, image_options = {}) binary = if image_options.key?(:transform) apply_custom_transformation(binary, image_options[:transform]) else apply_default_transformation(binary) end binary_url(binary) end def resolved_binary_obj_url(obj, binary) BinaryRewrite.call(request, apply_default_transformation(binary).url) end private def binary_url_from_cache(binary) if url_from_cache = binary.url_from_cache BinaryRewrite.call(request, url_from_cache) end end def binary_redirect_url(binary) encrypted_params = BinaryParamVerifier.generate(binary) scrivito_engine.binary_path(encrypted_params: encrypted_params) end def apply_custom_transformation(binary, transformation_definition) if transformation_definition binary.transform(transformation_definition) else binary end end def apply_default_transformation(binary) if Scrivito::Configuration.default_image_transformation binary.transform(Scrivito::Configuration.default_image_transformation) else binary end end end end
Version data entries
11 entries across 11 versions & 1 rubygems