Class: FileColumn::BaseUploadedFile
- Inherits:
-
Object
- Object
- FileColumn::BaseUploadedFile
show all
- Defined in:
- lib/file_column.rb
Overview
Instance Method Summary
collapse
Constructor Details
Returns a new instance of BaseUploadedFile.
51
52
53
54
|
# File 'lib/file_column.rb', line 51
def initialize(instance,attr)
@instance, @attr = instance, attr
@options_method = "#{attr}_options".to_sym
end
|
Instance Method Details
#absolute_dir ⇒ Object
105
106
107
|
# File 'lib/file_column.rb', line 105
def absolute_dir
if absolute_path then File.dirname(absolute_path) else nil end
end
|
#after_destroy ⇒ Object
118
119
|
# File 'lib/file_column.rb', line 118
def after_destroy
end
|
#after_save ⇒ Object
113
114
115
116
|
# File 'lib/file_column.rb', line 113
def after_save
@on_save.each { |blk| blk.call } if @on_save
self
end
|
#assign(file) ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/file_column.rb', line 60
def assign(file)
if file.is_a? File
file.extend FileColumn::FileCompat
end
if file.nil?
delete
else
if file.size == 0
self
else
if file.is_a?(String)
raise TypeError.new("Do not know how to handle a string with value '#{file}' that was passed to a file_column. Check if the form's encoding has been set to 'multipart/form-data'.")
end
upload(file)
end
end
end
|
#just_uploaded? ⇒ Boolean
90
91
92
|
# File 'lib/file_column.rb', line 90
def just_uploaded?
@just_uploaded
end
|
#on_save(&blk) ⇒ Object
94
95
96
97
|
# File 'lib/file_column.rb', line 94
def on_save(&blk)
@on_save ||= []
@on_save << Proc.new
end
|
#options ⇒ Object
121
122
123
|
# File 'lib/file_column.rb', line 121
def options
@instance.send(@options_method)
end
|
#relative_dir ⇒ Object
109
110
111
|
# File 'lib/file_column.rb', line 109
def relative_dir
if relative_path then File.dirname(relative_path) else nil end
end
|
#store ⇒ Object
56
57
58
|
# File 'lib/file_column.rb', line 56
def store
nil
end
|
#temp_path ⇒ Object
the following methods are overriden by sub-classes if needed
101
102
103
|
# File 'lib/file_column.rb', line 101
def temp_path
nil
end
|