Class: Attachie::Attachment::Version
- Inherits:
-
Object
- Object
- Attachie::Attachment::Version
show all
- Defined in:
- lib/attachie.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(attachment, name, options) ⇒ Version
Returns a new instance of Version.
22
23
24
25
26
|
# File 'lib/attachie.rb', line 22
def initialize(attachment, name, options)
self.attachment = attachment
self.name = name
self.options = options
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
92
93
94
95
96
|
# File 'lib/attachie.rb', line 92
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
|
Instance Attribute Details
#attachment ⇒ Object
Returns the value of attribute attachment.
20
21
22
|
# File 'lib/attachie.rb', line 20
def attachment
@attachment
end
|
#name ⇒ Object
Returns the value of attribute name.
20
21
22
|
# File 'lib/attachie.rb', line 20
def name
@name
end
|
#options ⇒ Object
Returns the value of attribute options.
20
21
22
|
# File 'lib/attachie.rb', line 20
def options
@options
end
|
Instance Method Details
#container ⇒ Object
Also known as:
bucket
44
45
46
|
# File 'lib/attachie.rb', line 44
def container
interpolate option(:container) || option(:bucket)
end
|
#delete ⇒ Object
76
77
78
|
# File 'lib/attachie.rb', line 76
def delete
option(:driver).delete(path, container)
end
|
#download(dest_path) ⇒ Object
64
65
66
|
# File 'lib/attachie.rb', line 64
def download(dest_path)
option(:driver).download(path, container, dest_path)
end
|
#exists? ⇒ Boolean
80
81
82
|
# File 'lib/attachie.rb', line 80
def exists?
option(:driver).exists?(path, container)
end
|
#info ⇒ Object
68
69
70
|
# File 'lib/attachie.rb', line 68
def info
option(:driver).info(path, container)
end
|
#inspect ⇒ Object
84
85
86
|
# File 'lib/attachie.rb', line 84
def inspect
to_s
end
|
#object ⇒ Object
88
89
90
|
# File 'lib/attachie.rb', line 88
def object
attachment.object
end
|
#path ⇒ Object
36
37
38
|
# File 'lib/attachie.rb', line 36
def path
"#{interpolate(option(:path_prefix)) + "/" if option(:path_prefix)}#{path_without_prefix}"
end
|
#path_without_prefix ⇒ Object
40
41
42
|
# File 'lib/attachie.rb', line 40
def path_without_prefix
interpolate option(:path)
end
|
#presigned_post(options = {}) ⇒ Object
28
29
30
|
# File 'lib/attachie.rb', line 28
def presigned_post(options = {})
option(:driver).presigned_post(path, container, options)
end
|
#respond_to_missing?(method_name, *args) ⇒ Boolean
98
99
100
|
# File 'lib/attachie.rb', line 98
def respond_to_missing?(method_name, *args)
attachment.options[:versions][name].key?(method_name.to_sym)
end
|
#store(data_or_io, opts = {}) ⇒ Object
60
61
62
|
# File 'lib/attachie.rb', line 60
def store(data_or_io, opts = {})
option(:driver).store(path, data_or_io, container, opts)
end
|
#store_multipart(opts = {}, &block) ⇒ Object
72
73
74
|
# File 'lib/attachie.rb', line 72
def store_multipart(opts = {}, &block)
option(:driver).store_multipart(path, container, opts, &block)
end
|
#temp_url(opts = {}) ⇒ Object
50
51
52
53
54
|
# File 'lib/attachie.rb', line 50
def temp_url(opts = {})
return url unless option(:driver).respond_to?(:temp_url)
option(:driver).temp_url(path, container, opts)
end
|
#url ⇒ Object
32
33
34
|
# File 'lib/attachie.rb', line 32
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 ⇒ Object
56
57
58
|
# File 'lib/attachie.rb', line 56
def value
option(:driver).value(path, container)
end
|