Sha256: b947467d30acbbea56c0cd5fefe0a6ff6e815b8e6720fc8ffb739bcceef35aea

Contents?: true

Size: 1013 Bytes

Versions: 6

Compression:

Stored size: 1013 Bytes

Contents

module CarrierWave
  module Uploader
    module Url
      extend ActiveSupport::Concern
      include CarrierWave::Uploader::Configuration
      include CarrierWave::Utilities::Uri

      ##
      # === Parameters
      #
      # [Hash] optional, the query params (only AWS)
      #
      # === Returns
      #
      # [String] the location where this file is accessible via a url
      #
      def url(options = {})
        if file.respond_to?(:url) and not file.url.blank?
          file.method(:url).arity == 0 ? file.url : file.url(options)
        elsif file.respond_to?(:path)
          path = encode_path(file.path.sub(File.expand_path(root), ''))

          if host = asset_host
            if host.respond_to? :call
              "#{host.call(file)}#{path}"
            else
              "#{host}#{path}"
            end
          else
            (base_path || "") + path
          end
        end
      end

      def to_s
        url || ''
      end

    end # Url
  end # Uploader
end # CarrierWave

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
carrierwave-1.0.0 lib/carrierwave/uploader/url.rb
carrierwave-1.0.0.rc lib/carrierwave/uploader/url.rb
card-1.19.3 vendor/carrierwave/lib/carrierwave/uploader/url.rb
card-1.19.2 vendor/carrierwave/lib/carrierwave/uploader/url.rb
carrierwave-1.0.0.beta lib/carrierwave/uploader/url.rb
card-1.19.1 vendor/carrierwave/lib/carrierwave/uploader/url.rb