Commit bc0758ca by Mike Burns

Move Paperclip-specific callback definitions into HasAttachedFile

parent b491f2a3
...@@ -174,8 +174,6 @@ module Paperclip ...@@ -174,8 +174,6 @@ module Paperclip
# end # end
def has_attached_file(name, options = {}) def has_attached_file(name, options = {})
HasAttachedFile.define_on(self, name, options) HasAttachedFile.define_on(self, name, options)
define_paperclip_callbacks :post_process, :"#{name}_post_process"
end end
end end
end end
......
...@@ -17,6 +17,7 @@ module Paperclip ...@@ -17,6 +17,7 @@ module Paperclip
define_query define_query
register_with_rake_tasks register_with_rake_tasks
add_active_record_callbacks add_active_record_callbacks
add_paperclip_callbacks
end end
private private
...@@ -75,5 +76,11 @@ module Paperclip ...@@ -75,5 +76,11 @@ module Paperclip
@klass.send(:before_destroy) { send(name).send(:queue_all_for_delete) } @klass.send(:before_destroy) { send(name).send(:queue_all_for_delete) }
@klass.send(:after_destroy) { send(name).send(:flush_deletes) } @klass.send(:after_destroy) { send(name).send(:flush_deletes) }
end end
def add_paperclip_callbacks
@klass.send(
:define_paperclip_callbacks,
:post_process, :"#{@name}_post_process")
end
end end
end end
...@@ -34,6 +34,10 @@ class HasAttachedFileTest < Test::Unit::TestCase ...@@ -34,6 +34,10 @@ class HasAttachedFileTest < Test::Unit::TestCase
should 'define an after_destroy callback' do should 'define an after_destroy callback' do
assert_adding_attachment('avatar').defines_callback('after_destroy') assert_adding_attachment('avatar').defines_callback('after_destroy')
end end
should 'define the Paperclip-specific callbacks' do
assert_adding_attachment('avatar').defines_callback('define_paperclip_callbacks')
end
end end
private private
...@@ -98,6 +102,7 @@ class HasAttachedFileTest < Test::Unit::TestCase ...@@ -98,6 +102,7 @@ class HasAttachedFileTest < Test::Unit::TestCase
after_save: nil, after_save: nil,
before_destroy: nil, before_destroy: nil,
after_destroy: nil, after_destroy: nil,
define_paperclip_callbacks: nil,
name: 'Billy') name: 'Billy')
end end
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