Module: Progstr::Filer::ActiveRecordClassMethods
- Includes:
- Validation
- Defined in:
- lib/filer/activerecord.rb
Instance Method Summary
collapse
Methods included from Validation
#validates_file_extension_of, #validates_file_size_of
Instance Method Details
#_uploaders ⇒ Object
8
9
10
11
12
13
14
15
16
|
# File 'lib/filer/activerecord.rb', line 8
def _uploaders
if @uploaders.nil?
@uploaders = {}
@uploaders = superclass._uploaders.merge(@uploaders) if superclass.respond_to?(:_uploaders)
after_save :"_filer_after_save"
before_destroy :"_filer_before_delete"
end
@uploaders
end
|
#has_file(attribute, uploaderClass) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/filer/activerecord.rb', line 18
def has_file(attribute, uploaderClass)
class_eval <<-RUBY, __FILE__, __LINE__+1
def #{attribute}
_get_attachment(:#{attribute})
end
def #{attribute}=(new_file)
_set_attachment(:#{attribute}, new_file)
end
def upload_#{attribute}!
_upload_attachment(:#{attribute})
end
RUBY
_uploaders[attribute] = uploaderClass.new
end
|