Commit bc0758ca by Mike Burns

Move Paperclip-specific callback definitions into HasAttachedFile

parent b491f2a3
......@@ -174,8 +174,6 @@ module Paperclip
# end
def has_attached_file(name, options = {})
HasAttachedFile.define_on(self, name, options)
define_paperclip_callbacks :post_process, :"#{name}_post_process"
end
end
end
......
......@@ -17,6 +17,7 @@ module Paperclip
define_query
register_with_rake_tasks
add_active_record_callbacks
add_paperclip_callbacks
end
private
......@@ -75,5 +76,11 @@ module Paperclip
@klass.send(:before_destroy) { send(name).send(:queue_all_for_delete) }
@klass.send(:after_destroy) { send(name).send(:flush_deletes) }
end
def add_paperclip_callbacks
@klass.send(
:define_paperclip_callbacks,
:post_process, :"#{@name}_post_process")
end
end
end
......@@ -34,6 +34,10 @@ class HasAttachedFileTest < Test::Unit::TestCase
should 'define an after_destroy callback' do
assert_adding_attachment('avatar').defines_callback('after_destroy')
end
should 'define the Paperclip-specific callbacks' do
assert_adding_attachment('avatar').defines_callback('define_paperclip_callbacks')
end
end
private
......@@ -98,6 +102,7 @@ class HasAttachedFileTest < Test::Unit::TestCase
after_save: nil,
before_destroy: nil,
after_destroy: nil,
define_paperclip_callbacks: nil,
name: 'Billy')
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment