Sha256: 7e58de777370326446dfd2bbae867a72ea3c32538d7090fdafacace00f0679ab

Contents?: true

Size: 1.11 KB

Versions: 33

Compression:

Stored size: 1.11 KB

Contents

# encoding: utf-8

require 'sequel'
 
module CarrierWave
  module Sequel
    include CarrierWave::Mount
 
    def mount_uploader(column, uploader)
      raise "You need to use Sequel 3.0 or higher. Please upgrade." unless ::Sequel::Model.respond_to?(:plugin)
      super
 
      alias_method :read_uploader, :[]
      alias_method :write_uploader, :[]=
 
      include CarrierWave::Sequel::Hooks
      include CarrierWave::Sequel::Validations
    end

  end # Sequel
end # CarrierWave
 
# Instance hook methods for the Sequel 3.x
module CarrierWave::Sequel::Hooks
  def after_save
    return false if super == false
    self.class.uploaders.each_key {|column| self.send("store_#{column}!") }
  end

  def before_save
    return false if super == false
    self.class.uploaders.each_key {|column| self.send("write_#{column}_identifier") }
  end

  def before_destroy
    return false if super == false
    self.class.uploaders.each_key {|column| self.send("remove_#{column}!") }
  end
end

# Instance validation methods for the Sequel 3.x
module CarrierWave::Sequel::Validations
end

Sequel::Model.send(:extend, CarrierWave::Sequel)

Version data entries

33 entries across 33 versions & 8 rubygems

Version Path
locomotive_carrierwave-0.5.0.1.beta3 lib/carrierwave/orm/sequel.rb
carrierwave-0.5.1 lib/carrierwave/orm/sequel.rb
thorsson_carrierwave-0.4.12 lib/carrierwave/orm/sequel.rb
thorsson_carrierwave-0.4.11 lib/carrierwave/orm/sequel.rb
thorsson_carrierwave-0.4.10 lib/carrierwave/orm/sequel.rb
thorsson_carrierwave-0.4.9 lib/carrierwave/orm/sequel.rb
thorsson_carrierwave-0.4.8 lib/carrierwave/orm/sequel.rb
thorsson_carrierwave-0.4.6 lib/carrierwave/orm/sequel.rb
thorsson_carrierwave-0.4.5 lib/carrierwave/orm/sequel.rb
locomotive_carrierwave-0.5.0.1.beta2 lib/carrierwave/orm/sequel.rb
locomotive_carrierwave-0.5.0.1.beta1 lib/carrierwave/orm/sequel.rb
locomotive_carrierwave-0.5.0.1 lib/carrierwave/orm/sequel.rb
carrierwave-0.5.0 lib/carrierwave/orm/sequel.rb
carrierwave-0.4.10 lib/carrierwave/orm/sequel.rb
jswanner-carrierwave-0.5.0.beta3 lib/carrierwave/orm/sequel.rb
carrierwave-0.4.9 lib/carrierwave/orm/sequel.rb
carrierwave-0.5.0.beta2 lib/carrierwave/orm/sequel.rb
carrierwave-0.4.8 lib/carrierwave/orm/sequel.rb
carrierwave-0.4.7 lib/carrierwave/orm/sequel.rb
carrierwave-0.4.6 lib/carrierwave/orm/sequel.rb