Sha256: 491e2b2909561942df3f6e19b843b9dd201b70ea181207e7d85f219a02e81546

Contents?: true

Size: 978 Bytes

Versions: 4

Compression:

Stored size: 978 Bytes

Contents

# encoding: utf-8

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

      ##
      # === 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 = file.path.gsub(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

4 entries across 4 versions & 2 rubygems

Version Path
carrierwave-0.8.0 lib/carrierwave/uploader/url.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/carrierwave-0.7.1/lib/carrierwave/uploader/url.rb
carrierwave-0.7.1 lib/carrierwave/uploader/url.rb
carrierwave-0.7.0 lib/carrierwave/uploader/url.rb