Module: Paperclip::Callbacks::Defining

Defined in:
lib/paperclip/callbacks.rb

Instance Method Summary collapse

Instance Method Details

#define_paperclip_callbacks(*callbacks) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/paperclip/callbacks.rb', line 9

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