Sha256: 4bf0104e9d19271a7d30a57b10b3ff3f95013eaf4a5998911ac2c0d03c6ab27e

Contents?: true

Size: 956 Bytes

Versions: 31

Compression:

Stored size: 956 Bytes

Contents

module CarrierWave
  module Uploader
    module Callbacks
      extend ActiveSupport::Concern

      included do
        class_attribute :_before_callbacks, :_after_callbacks,
          :instance_writer => false
        self._before_callbacks = Hash.new []
        self._after_callbacks = Hash.new []
      end

      def with_callbacks(kind, *args)
        self.class._before_callbacks[kind].each { |c| send c, *args }
        yield
        self.class._after_callbacks[kind].each { |c| send c, *args }
      end

      module ClassMethods
        def before(kind, callback)
          self._before_callbacks = self._before_callbacks.
            merge kind => _before_callbacks[kind] + [callback]
        end

        def after(kind, callback)
          self._after_callbacks = self._after_callbacks.
            merge kind => _after_callbacks[kind] + [callback]
        end
      end # ClassMethods

    end # Callbacks
  end # Uploader
end # CarrierWave

Version data entries

31 entries across 31 versions & 3 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/carrierwave-2.2.6/lib/carrierwave/uploader/callbacks.rb
carrierwave-2.2.6 lib/carrierwave/uploader/callbacks.rb
carrierwave-2.2.5 lib/carrierwave/uploader/callbacks.rb
carrierwave-1.3.4 lib/carrierwave/uploader/callbacks.rb
carrierwave-2.2.4 lib/carrierwave/uploader/callbacks.rb
carrierwave-1.3.3 lib/carrierwave/uploader/callbacks.rb
carrierwave-2.2.3 lib/carrierwave/uploader/callbacks.rb
carrierwave-3.0.0.beta lib/carrierwave/uploader/callbacks.rb
carrierwave-2.2.2 lib/carrierwave/uploader/callbacks.rb
carrierwave-2.2.1 lib/carrierwave/uploader/callbacks.rb
carrierwave-2.2.0 lib/carrierwave/uploader/callbacks.rb
carrierwave-2.1.1 lib/carrierwave/uploader/callbacks.rb
carrierwave-1.3.2 lib/carrierwave/uploader/callbacks.rb
carrierwave-2.1.0 lib/carrierwave/uploader/callbacks.rb
carrierwave-2.0.2 lib/carrierwave/uploader/callbacks.rb
carrierwave-2.0.1 lib/carrierwave/uploader/callbacks.rb
carrierwave-2.0.0 lib/carrierwave/uploader/callbacks.rb
carrierwave-2.0.0.rc lib/carrierwave/uploader/callbacks.rb
carrierwave-1.3.1 lib/carrierwave/uploader/callbacks.rb
carrierwave-1.3.0 lib/carrierwave/uploader/callbacks.rb