Sha256: 55ace68e00052737c53763abb2254890fc13027eadf8fc01a58b51df0df15a14

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

module CarrierWaveDelay
    module Model

        extend ActiveSupport::Concern

        included do
            cattr_accessor :carrierwave_delay_columns
        end

        module ClassMethods

            def carrierwave_delay columns
                after_save :carrierwave_delay_process
                self.carrierwave_delay_columns = columns
            end

            def carrierwave_delay_queue
                :default
            end
            def carrierwave_delay_priority
                20
            end

        end

        def recreate_delayed_versions!
            self.class.carrierwave_delay_columns.each do |column|
                unless self.send(column).nil?
                    send(column).is_processing_delayed = true
                    send(column).recreate_versions!
                end
            end
        end

        private

        def carrierwave_delay_process
            self.delay(queue: self.class.carrierwave_delay_queue, priority: self.class.carrierwave_delay_priority).recreate_delayed_versions!
        end

    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
carrierwave-delay-0.1.1 lib/carrierwave-delay/model.rb