Sha256: 66f5d2e0b4287243efa665853421c2036c264cae3d30bc501e281a5b083bb5a1

Contents?: true

Size: 759 Bytes

Versions: 9

Compression:

Stored size: 759 Bytes

Contents

# encoding: utf-8

module CarrierWave
  module Uploader
    module Url

      ##
      # === Returns
      #
      # [String] the location where this file is accessible via a url
      #
      def url
        if file.respond_to?(:url) and not file.url.blank?
          file.url
        elsif current_path
          File.expand_path(current_path).gsub(File.expand_path(root), '')
        end
      end

      alias_method :to_s, :url

      ##
      # === Returns
      #
      # [String] A JSON serialization containing this uploader's URL(s)
      #
      def as_json(options = nil)
        h = { :url => url }
        h.merge Hash[versions.map { |name, version| [name, { :url => version.url }] }]
      end

    end # Url
  end # Uploader
end # CarrierWave

Version data entries

9 entries across 9 versions & 3 rubygems

Version Path
potatosalad-carrierwave-0.5.7.1 lib/carrierwave/uploader/url.rb
potatosalad-carrierwave-0.5.7 lib/carrierwave/uploader/url.rb
carrierwave-0.5.6 lib/carrierwave/uploader/url.rb
carrierwave-0.5.5 lib/carrierwave/uploader/url.rb
locomotive_carrierwave-0.5.4.beta3 lib/carrierwave/uploader/url.rb
locomotive_carrierwave-0.5.4.beta2 lib/carrierwave/uploader/url.rb
locomotive_carrierwave-0.5.4.beta1 lib/carrierwave/uploader/url.rb
carrierwave-0.5.4 lib/carrierwave/uploader/url.rb
carrierwave-0.5.3 lib/carrierwave/uploader/url.rb