Sha256: 32d3f95636646196fa49125aad7d31c3e7ca0ea5b10a8d1f23ce411809129996

Contents?: true

Size: 1014 Bytes

Versions: 1

Compression:

Stored size: 1014 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
      #
      # [Hash] the locations where this file and versions are accessible via a url
      #
      def as_json(options = nil)
        h = { :url => url }
        h.merge Hash[versions.map { |name, version| [name, { :url => version.url }] }]
      end

      ##
      # FIXME to_xml should work like to_json, but this is the best we've been able to do so far.
      # This hack fixes issue #337.
      #
      # === Returns
      #
      # [nil]
      #
      def to_xml(options = nil)
      end

    end # Url
  end # Uploader
end # CarrierWave

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
carrierwave-0.5.7 lib/carrierwave/uploader/url.rb