Sha256: d7ad264fe52915a220a733845fab261189958502cf49d550d50460713f8e5ba2

Contents?: true

Size: 959 Bytes

Versions: 58

Compression:

Stored size: 959 Bytes

Contents

# frozen_string_literal: true

module Alchemy
  class Attachment < BaseRecord
    # The class representing an URL to an attachment
    #
    # Set a different one
    #
    #     Alchemy::Attachment.url_class = MyRemoteUrlClass
    #
    class Url
      def initialize(attachment)
        @attachment = attachment
      end

      # The attachment url
      #
      # @param [Hash] options
      # @option options [Symbol] :download return a URL for downloading the attachment
      # @option options [Symbol] :name The filename
      # @option options [Symbol] :format The file extension
      #
      # @return [String]
      #
      def call(options = {})
        if options.delete(:download)
          routes.download_attachment_path(@attachment, options)
        else
          routes.show_attachment_path(@attachment, options)
        end
      end

      private

      def routes
        Alchemy::Engine.routes.url_helpers
      end
    end
  end
end

Version data entries

58 entries across 58 versions & 1 rubygems

Version Path
alchemy_cms-6.0.0.pre.b6 app/models/alchemy/attachment/url.rb
alchemy_cms-6.0.0.pre.b5 app/models/alchemy/attachment/url.rb
alchemy_cms-6.0.0.pre.b4 app/models/alchemy/attachment/url.rb
alchemy_cms-6.0.0.b3 app/models/alchemy/attachment/url.rb
alchemy_cms-6.0.0.b2 app/models/alchemy/attachment/url.rb
alchemy_cms-6.0.0.b1 app/models/alchemy/attachment/url.rb
alchemy_cms-5.2.1 app/models/alchemy/attachment/url.rb
alchemy_cms-5.1.4 app/models/alchemy/attachment/url.rb
alchemy_cms-5.1.3 app/models/alchemy/attachment/url.rb
alchemy_cms-5.2.0 app/models/alchemy/attachment/url.rb
alchemy_cms-5.2.0.rc1 app/models/alchemy/attachment/url.rb
alchemy_cms-5.2.0.b1 app/models/alchemy/attachment/url.rb
alchemy_cms-5.1.2 app/models/alchemy/attachment/url.rb
alchemy_cms-5.1.1 app/models/alchemy/attachment/url.rb
alchemy_cms-5.1.0 app/models/alchemy/attachment/url.rb
alchemy_cms-5.1.0.rc1 app/models/alchemy/attachment/url.rb
alchemy_cms-5.1.0.beta2 app/models/alchemy/attachment/url.rb
alchemy_cms-5.1.0.beta1 app/models/alchemy/attachment/url.rb