Commit ae7c0a48089b3ef01eb6c2a9dbe8643cda1242eb
Committed by
Leandro Santos
1 parent
fcf8fd0f
Exists in
web_steps_improvements
and in
6 other branches
add patch methods to prepare callback
Showing
1 changed file
with
18 additions
and
17 deletions
Show diff stats
vendor/plugins/monkey_patches/attachment_fu/init.rb
| ... | ... | @@ -3,26 +3,27 @@ |
| 3 | 3 | |
| 4 | 4 | require_dependency 'technoweenie/attachment_fu' |
| 5 | 5 | |
| 6 | -Technoweenie::AttachmentFu::InstanceMethods.module_eval do | |
| 7 | - def thumbnailable? | |
| 8 | - image? && !is_thumbnail? | |
| 9 | - end | |
| 6 | +ActionDispatch::Reloader.to_prepare do | |
| 7 | + Technoweenie::AttachmentFu::InstanceMethods.module_eval do | |
| 8 | + def thumbnailable? | |
| 9 | + image? && !is_thumbnail? | |
| 10 | + end | |
| 10 | 11 | |
| 11 | - def is_thumbnail? | |
| 12 | - (thumbnail_class == self.class) && !(respond_to?(:parent_id) && parent_id.nil?) | |
| 12 | + def is_thumbnail? | |
| 13 | + (thumbnail_class == self.class) && !(respond_to?(:parent_id) && parent_id.nil?) | |
| 14 | + end | |
| 13 | 15 | end |
| 14 | -end | |
| 15 | 16 | |
| 16 | -# Monkey patch to rewrite attachment_fu's logic where no image with parent can | |
| 17 | -# be thumbnailable and supposition that full_filename will return a String | |
| 18 | -# while it might return Pathname. | |
| 19 | -Technoweenie::AttachmentFu::Backends::FileSystemBackend.module_eval do | |
| 20 | - def attachment_path_id | |
| 21 | - (is_thumbnail? && respond_to?(:parent_id)) ? parent_id : id | |
| 22 | - end | |
| 17 | + # Monkey patch to rewrite attachment_fu's logic where no image with parent can | |
| 18 | + # be thumbnailable and supposition that full_filename will return a String | |
| 19 | + # while it might return Pathname. | |
| 20 | + Technoweenie::AttachmentFu::Backends::FileSystemBackend.module_eval do | |
| 21 | + def attachment_path_id | |
| 22 | + (is_thumbnail? && respond_to?(:parent_id)) ? parent_id : id | |
| 23 | + end | |
| 23 | 24 | |
| 24 | - def public_filename(thumbnail = nil) | |
| 25 | - full_filename(thumbnail).to_s.gsub %r(^#{Regexp.escape(base_path)}), '' | |
| 25 | + def public_filename(thumbnail = nil) | |
| 26 | + full_filename(thumbnail).to_s.gsub %r(^#{Regexp.escape(base_path)}), '' | |
| 27 | + end | |
| 26 | 28 | end |
| 27 | 29 | end |
| 28 | - | ... | ... |