Class: CdnFu::Uploader
- Inherits:
-
Object
show all
- Defined in:
- lib/cdn_fu/uploader.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.optional_attributes(*arr) ⇒ Object
Also known as:
optional_attribute
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/cdn_fu/uploader.rb', line 20
def optional_attributes( *arr )
return @optional_attributes if arr.size == 0
@optional_attributes ||= []
arr.each do |a|
@optional_attributes << a.to_sym
class_eval do
define_method(a.to_sym) do |*args|
return instance_variable_get("@#{a}") if args.size == 0
instance_variable_set("@#{a}",args[0])
end
end
end
end
|
.required_attributes(*arr) ⇒ Object
Also known as:
required_attribute
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/cdn_fu/uploader.rb', line 6
def required_attributes( *arr )
return @required_attributes if arr.size == 0
@required_attributes ||= []
arr.each do |a|
@required_attributes << a.to_sym
class_eval do
define_method(a.to_sym) do |*args|
return instance_variable_get("@#{a}") if args.size == 0
instance_variable_set("@#{a}",args[0])
end
end
end
end
|
Instance Method Details
#attribute_validate ⇒ Object
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/cdn_fu/uploader.rb', line 45
def attribute_validate
if self.class.required_attributes
self.class.required_attributes.each do |attr|
res = self.send(attr)
if res.nil? or res == ''
raise CdnFuConfigError, "#{attr} must be specified in the uploader configuration"
end
end
end
end
|
#validate ⇒ Object
56
57
|
# File 'lib/cdn_fu/uploader.rb', line 56
def validate
end
|
#validate_and_upload(file_list) ⇒ Object
39
40
41
42
43
|
# File 'lib/cdn_fu/uploader.rb', line 39
def validate_and_upload(file_list)
attribute_validate
validate
upload(file_list)
end
|