14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/architect4r/adapters/carrier_wave.rb', line 14
def mount_uploader(column, uploader = nil, options = {}, &block)
property "#{column}_data", :cast_to => String
super
include ::CarrierWave::Validations::ActiveModel
validates_integrity_of column if uploader_option(column.to_sym, :validate_integrity)
validates_processing_of column if uploader_option(column.to_sym, :validate_processing)
after_save :"store_#{column}!"
before_save :"write_#{column}_identifier"
after_destroy :"remove_#{column}!"
class_eval <<-RUBY, __FILE__, __LINE__+1
public
def read_uploader(column)
self.send("#{column}_data")
end
def write_uploader(column, identifier)
self.send("#{column}_data=", identifier)
end
RUBY
end
|