Sha256: f100aaed865aa1cac6daf46b5c400b8f823d6548be8bcc954cfaed225c24507c

Contents?: true

Size: 999 Bytes

Versions: 24

Compression:

Stored size: 999 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

    def page_file_path(*args)
      ActiveSupport::Deprecation.warn(
        "#page_file_path is deprecated, use #attachment_path"
      )
      page_file = args.detect { |a| a.is_a?(PageFile) }
      return attachment_path(page_file.attachment) if page_file

      super(*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

24 entries across 24 versions & 1 rubygems

Version Path
pages_core-3.14.0 app/helpers/pages_core/attachments_helper.rb
pages_core-3.13.0 app/helpers/pages_core/attachments_helper.rb
pages_core-3.12.7 app/helpers/pages_core/attachments_helper.rb
pages_core-3.12.6 app/helpers/pages_core/attachments_helper.rb
pages_core-3.12.5 app/helpers/pages_core/attachments_helper.rb
pages_core-3.12.4 app/helpers/pages_core/attachments_helper.rb
pages_core-3.12.3 app/helpers/pages_core/attachments_helper.rb
pages_core-3.12.2 app/helpers/pages_core/attachments_helper.rb
pages_core-3.12.1 app/helpers/pages_core/attachments_helper.rb
pages_core-3.12.0 app/helpers/pages_core/attachments_helper.rb
pages_core-3.11.3 app/helpers/pages_core/attachments_helper.rb
pages_core-3.11.2 app/helpers/pages_core/attachments_helper.rb
pages_core-3.11.1 app/helpers/pages_core/attachments_helper.rb
pages_core-3.11.0 app/helpers/pages_core/attachments_helper.rb
pages_core-3.10.2 app/helpers/pages_core/attachments_helper.rb
pages_core-3.10.1 app/helpers/pages_core/attachments_helper.rb
pages_core-3.9.2 app/helpers/pages_core/attachments_helper.rb
pages_core-3.9.1 app/helpers/pages_core/attachments_helper.rb
pages_core-3.9.0 app/helpers/pages_core/attachments_helper.rb
pages_core-3.8.3 app/helpers/pages_core/attachments_helper.rb