Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Fixed only_process option with proc #2289

Merged
merged 1 commit into from
Aug 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/paperclip/attachment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,8 @@ def dirty?
# the instance's errors and returns false, cancelling the save.
def save
flush_deletes unless @options[:keep_old_files]
if @options[:only_process].any? && !@options[:only_process].include?(:original)
process = only_process
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be better to memoize only_process method?
If it's called somewhere else, proc will be computed again. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be better to memoize only_process method?
If it's called somewhere else, proc will be computed again. What do you think?

Could that present regressions? For now, I'd rather not cache it, and wait for it to actually become a bottleneck to discuss if we should go down that road. Thanks!

if process.any? && !process.include?(:original)
@queued_for_write.except!(:original)
end
flush_writes
Expand Down
1 change: 1 addition & 0 deletions spec/paperclip/attachment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@
@attachment.expects(:post_process).with(:thumb)
@attachment.expects(:post_process).with(:large).never
@attachment.assign(@file)
@attachment.save
end
end

Expand Down