Module: CarrierWave::AWS::Record::Model

Includes:
Mount
Defined in:
lib/carrierwave/aws/record/model.rb,
lib/carrierwave/aws/record/model/version.rb

Defined Under Namespace

Modules: Hooks, Uploaders, Validations

Constant Summary collapse

VERSION =
"0.0.1"

Instance Method Summary collapse

Instance Method Details

#mount_uploader(column, uploader = nil, options = {}, &block) ⇒ Object

See CarrierWave::Mount#mount_uploader for documentation



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/carrierwave/aws/record/model.rb', line 17

def mount_uploader(column, uploader=nil, options={}, &block)
  string_attr options[:mount_on] || "#{column}_store".to_sym
  super

  include CarrierWave::Validations::ActiveModel
  include CarrierWave::AWS::Record::Model::Uploaders

  #validates_integrity_of column if uploader_option(column.to_sym, :validate_integrity)
  #validates_processing_of column if uploader_option(column.to_sym, :validate_processing)
  #validates_download_of column if uploader_option(column.to_sym, :validate_download)

  after_save :"store_#{column}!"
  before_save :"write_#{column}_identifier"
  after_destroy :"remove_#{column}!"
  before_update :"store_previous_model_for_#{column}"
  after_save :"remove_previously_stored_#{column}"

  class_eval <<-RUBY, __FILE__, __LINE__+1
    def #{column}_changed?
      #{column}_store_changed?
    end
  RUBY
end