class Attachie::Attachment::Version
Attributes
attachment[RW]
name[RW]
options[RW]
Public Class Methods
new(attachment, name, options)
click to toggle source
# File lib/attachie.rb, line 20 def initialize(attachment, name, options) self.attachment = attachment self.name = name self.options = options end
Public Instance Methods
container()
click to toggle source
# File lib/attachie.rb, line 42 def container interpolate option(:container) || option(:bucket) end
Also aliased as: bucket
delete()
click to toggle source
# File lib/attachie.rb, line 74 def delete option(:driver).delete(path, container) end
download(dest_path)
click to toggle source
# File lib/attachie.rb, line 62 def download(dest_path) option(:driver).download(path, container, dest_path) end
exists?()
click to toggle source
# File lib/attachie.rb, line 78 def exists? option(:driver).exists?(path, container) end
info()
click to toggle source
# File lib/attachie.rb, line 66 def info option(:driver).info(path, container) end
inspect()
click to toggle source
# File lib/attachie.rb, line 82 def inspect to_s end
method_missing(method_name, *args, &block)
click to toggle source
Calls superclass method
# File lib/attachie.rb, line 90 def method_missing(method_name, *args, &block) return attachment.options[:versions][name][method_name.to_sym] if attachment.options[:versions][name].key?(method_name.to_sym) super end
object()
click to toggle source
# File lib/attachie.rb, line 86 def object attachment.object end
path()
click to toggle source
# File lib/attachie.rb, line 34 def path "#{interpolate(option(:path_prefix)) + "/" if option(:path_prefix)}#{path_without_prefix}" end
path_without_prefix()
click to toggle source
# File lib/attachie.rb, line 38 def path_without_prefix interpolate option(:path) end
presigned_post(options = {})
click to toggle source
# File lib/attachie.rb, line 26 def presigned_post(options = {}) option(:driver).presigned_post(path, container, options) end
respond_to_missing?(method_name, *args)
click to toggle source
# File lib/attachie.rb, line 96 def respond_to_missing?(method_name, *args) attachment.options[:versions][name].key?(method_name.to_sym) end
store(data_or_io, opts = {})
click to toggle source
# File lib/attachie.rb, line 58 def store(data_or_io, opts = {}) option(:driver).store(path, data_or_io, container, opts) end
store_multipart(opts = {}, &block)
click to toggle source
# File lib/attachie.rb, line 70 def store_multipart(opts = {}, &block) option(:driver).store_multipart(path, container, opts, &block) end
temp_url(opts = {})
click to toggle source
# File lib/attachie.rb, line 48 def temp_url(opts = {}) return url unless option(:driver).respond_to?(:temp_url) option(:driver).temp_url(path, container, opts) end
url()
click to toggle source
# File lib/attachie.rb, line 30 def url "#{interpolate option(:protocol)}://#{interpolate option(:host)}/#{interpolate(option(:url_prefix)).to_s + "/" if option(:url_prefix)}#{path}#{interpolate(option(:url_suffix)) if option(:url_suffix)}" end
value()
click to toggle source
# File lib/attachie.rb, line 54 def value option(:driver).value(path, container) end
Private Instance Methods
interpolate(str)
click to toggle source
# File lib/attachie.rb, line 110 def interpolate(str) raise(InterpolationError) unless str.is_a?(String) str.gsub(/(?<!\\):[a-zA-Z][a-zA-Z0-9_]*/) do |attribute_name| Interpolation.new(self).send(attribute_name.gsub(/^:/, "")) end end
option(option_name)
click to toggle source
# File lib/attachie.rb, line 102 def option(option_name) return attachment.options[:versions][name][option_name] if attachment.options[:versions][name].key?(option_name) return options[option_name] if options.key?(option_name) return attachment.options[option_name] if attachment.options.key?(option_name) Attachie.default_options[option_name] end