Sha256: a4e588eb2a80e050cae0c801052b8a08423c41664e39c78d60ac9af33d4c028f

Contents?: true

Size: 1014 Bytes

Versions: 1

Compression:

Stored size: 1014 Bytes

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|
                send(column).is_processing_delayed = true
                send(column).recreate_versions!
            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.0 lib/carrierwave-delay/model.rb