Sha256: 3d739c5f8dfba2a80579381de95b55619d50c4a39155ab690c54e7500063db2f

Contents?: true

Size: 711 Bytes

Versions: 1

Compression:

Stored size: 711 Bytes

Contents

# frozen_string_literal: true

module PagesCore
  module AttachmentsHelper
    def attachment_path(*args)
      super(*attachment_params(args))
    end

    def download_attachment_path(*args)
      super(*attachment_params(args))
    end

    private

    def attachment_params(args)
      attachment = args.detect { |a| a.is_a?(Attachment) }
      args = [attachment.digest] + args if args.first == attachment
      if args.last.is_a?(Hash)
        args.last[:format] = attachment.filename_extension
      else
        args.push(format: attachment.filename_extension)
      end
      args
    end

    def attachment_digest(attachment)
      Attachment.verifier.generate(attachment.id.to_s)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pages_core-3.15.5 app/helpers/pages_core/attachments_helper.rb