lib/carrierwave/uploader/proxy.rb in carrierwave-0.11.2 vs lib/carrierwave/uploader/proxy.rb in carrierwave-1.0.0.beta
- old
+ new
@@ -1,7 +1,5 @@
-# encoding: utf-8
-
module CarrierWave
module Uploader
module Proxy
##
@@ -17,11 +15,11 @@
# === Returns
#
# [String] the path where the file is currently located.
#
def current_path
- file.path if file.respond_to?(:path)
+ file.try(:path)
end
alias_method :path, :current_path
##
@@ -30,33 +28,33 @@
# === Returns
#
# [String] uniquely identifies a file
#
def identifier
- storage.identifier if storage.respond_to?(:identifier)
+ storage.try(:identifier)
end
##
# Read the contents of the file
#
# === Returns
#
# [String] contents of the file
#
def read
- file.read if file.respond_to?(:read)
+ file.try(:read)
end
##
# Fetches the size of the currently stored/cached file
#
# === Returns
#
# [Integer] size of the file
#
def size
- file.respond_to?(:size) ? file.size : 0
+ file.try(:size) || 0
end
##
# Return the size of the file when asked for its length
#
@@ -78,10 +76,10 @@
# === Returns
#
# [String] content type of the file
#
def content_type
- file.respond_to?(:content_type) ? file.content_type : nil
+ file.try(:content_type)
end
end # Proxy
end # Uploader
end # CarrierWave