Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
paperclip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
paperclip
Commits
bc0758ca
Commit
bc0758ca
authored
May 03, 2013
by
Mike Burns
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move Paperclip-specific callback definitions into HasAttachedFile
parent
b491f2a3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
2 deletions
+12
-2
lib/paperclip.rb
+0
-2
lib/paperclip/has_attached_file.rb
+7
-0
test/has_attached_file_test.rb
+5
-0
No files found.
lib/paperclip.rb
View file @
bc0758ca
...
@@ -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
...
...
lib/paperclip/has_attached_file.rb
View file @
bc0758ca
...
@@ -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
test/has_attached_file_test.rb
View file @
bc0758ca
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment