Sha256: 80d596c564e223d6a5aa804c8d9756d8cbdde333fa8552126631bc026d7373f9

Contents?: true

Size: 1021 Bytes

Versions: 21

Compression:

Stored size: 1021 Bytes

Contents

module Paperclip
  module Callbacks
    def self.included(base)
      base.extend(Defining)
      base.send(:include, Running)
    end

    module Defining
      def define_paperclip_callbacks(*callbacks)
        define_callbacks(*[callbacks, {:terminator => callback_terminator}].flatten)
        callbacks.each do |callback|
          eval <<-end_callbacks
            def before_#{callback}(*args, &blk)
              set_callback(:#{callback}, :before, *args, &blk)
            end
            def after_#{callback}(*args, &blk)
              set_callback(:#{callback}, :after, *args, &blk)
            end
          end_callbacks
        end
      end

      private

      def callback_terminator
        if ::ActiveSupport::VERSION::STRING >= '4.1'
          lambda { |target, result| result == false }
        else
          'result == false'
        end
      end
    end

    module Running
      def run_paperclip_callbacks(callback, &block)
        run_callbacks(callback, &block)
      end
    end
  end
end

Version data entries

21 entries across 19 versions & 4 rubygems

Version Path
kt-paperclip-4.4.0 lib/paperclip/callbacks.rb
paperclip-4.3.7 lib/paperclip/callbacks.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/paperclip-4.3.6/lib/paperclip/callbacks.rb
paperclip-4.3.6 lib/paperclip/callbacks.rb
paperclip-4.3.5 lib/paperclip/callbacks.rb
paperclip-4.3.4 lib/paperclip/callbacks.rb
paperclip-4.3.3 lib/paperclip/callbacks.rb
paperclip-4.3.2 lib/paperclip/callbacks.rb
paperclip-4.3.1 lib/paperclip/callbacks.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/paperclip-4.2.4/lib/paperclip/callbacks.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/paperclip-4.2.4/lib/paperclip/callbacks.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/paperclip-4.2.3/lib/paperclip/callbacks.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/paperclip-4.2.2/lib/paperclip/callbacks.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/paperclip-4.2.4/lib/paperclip/callbacks.rb
paperclip-4.3.0 lib/paperclip/callbacks.rb
paperclip-4.2.4 lib/paperclip/callbacks.rb
paperclip-4.2.3 lib/paperclip/callbacks.rb
paperclip-4.2.2 lib/paperclip/callbacks.rb
paperclip-4.2.1 lib/paperclip/callbacks.rb
paperclip-4.2.0 lib/paperclip/callbacks.rb