Sha256: 4674ee0e162b427f3d21fa6c90d92e6ad87c0403c707cdfd31670f7ee3ba1863
Contents?: true
Size: 1.15 KB
Versions: 9
Compression:
Stored size: 1.15 KB
Contents
# encoding: utf-8 module CarrierWave module Uploader module Callbacks extend ActiveSupport::Concern included do class_inheritable_accessor :_before_callbacks, :_after_callbacks end def with_callbacks(kind, *args) self.class._before_callbacks_for(kind).each { |callback| self.send(callback, *args) } yield self.class._after_callbacks_for(kind).each { |callback| self.send(callback, *args) } end module ClassMethods def _before_callbacks_for(kind) #:nodoc: (self._before_callbacks || { kind => [] })[kind] || [] end def _after_callbacks_for(kind) #:nodoc: (self._after_callbacks || { kind => [] })[kind] || [] end def before(kind, callback) self._before_callbacks ||= {} self._before_callbacks[kind] = _before_callbacks_for(kind) + [callback] end def after(kind, callback) self._after_callbacks ||= {} self._after_callbacks[kind] = _after_callbacks_for(kind) + [callback] end end # ClassMethods end # Callbacks end # Uploader end # CarrierWave
Version data entries
9 entries across 9 versions & 4 rubygems