Sha256: 1fcd2b2f6a46beb0866de223571ddd22ee5408ef22f25f0ba80b23747a9d448e

Contents?: true

Size: 802 Bytes

Versions: 8

Compression:

Stored size: 802 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 => "result == false"}].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
    end

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
paperclip-3.5.4 lib/paperclip/callbacks.rb
paperclip-3.5.3 lib/paperclip/callbacks.rb
paperclip-3.5.2 lib/paperclip/callbacks.rb
paperclip-3.5.1 lib/paperclip/callbacks.rb
paperclip-3.5.0 lib/paperclip/callbacks.rb
paperclip-3.4.2 lib/paperclip/callbacks.rb
paperclip-3.4.1 lib/paperclip/callbacks.rb
paperclip-3.4.0 lib/paperclip/callbacks.rb