Sha256: 3a56fd5ff69915926ba9e6d00946b18f40051a43bf0cea1f3c872d6fafad1636

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

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
plowdawg-carrierwave-0.5.8 lib/carrierwave/uploader/url.rb