Sha256: 554817a1d6afef7f553fb1319ac438e3a3eddf6e65bf93a2559f016f8c949ded

Contents?: true

Size: 932 Bytes

Versions: 13

Compression:

Stored size: 932 Bytes

Contents

require 'carrierwave'
require 'carrierwave/validations/active_model'

module CarrierWave
  module DynaModel
    include CarrierWave::Mount

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

      super

      alias_method :read_uploader, :[]
      alias_method :write_uploader, :[]=
      public :read_uploader
      public :write_uploader

      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}!".to_sym
      before_save "write_#{column}_identifier".to_sym
      after_destroy "remove_#{column}!".to_sym

    end

  end
end

DynaModel::Document::ClassMethods.send(:include, CarrierWave::DynaModel)

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
dyna_model-0.0.15 lib/dyna_model/adapters/carrierwave/dyna_model.rb
dyna_model-0.0.14 lib/dyna_model/adapters/carrierwave/dyna_model.rb
dyna_model-0.0.13 lib/dyna_model/adapters/carrierwave/dyna_model.rb
dyna_model-0.0.12 lib/dyna_model/adapters/carrierwave/dyna_model.rb
dyna_model-0.0.11 lib/dyna_model/adapters/carrierwave/dyna_model.rb
dyna_model-0.0.10 lib/dyna_model/adapters/carrierwave/dyna_model.rb
dyna_model-0.0.9 lib/dyna_model/adapters/carrierwave/dyna_model.rb
dyna_model-0.0.8 lib/dyna_model/adapters/carrierwave/dyna_model.rb
dyna_model-0.0.7 lib/dyna_model/adapters/carrierwave/dyna_model.rb
dyna_model-0.0.6 lib/dyna_model/adapters/carrierwave/dyna_model.rb
dyna_model-0.0.5 lib/dyna_model/adapters/carrierwave/dyna_model.rb
dyna_model-0.0.4 lib/dyna_model/adapters/carrierwave/dyna_model.rb
dyna_model-0.0.3 lib/dyna_model/adapters/carrierwave/dyna_model.rb