From ae7c0a48089b3ef01eb6c2a9dbe8643cda1242eb Mon Sep 17 00:00:00 2001 From: Marcelo JĂșnior Date: Tue, 23 Feb 2016 21:12:53 -0300 Subject: [PATCH] add patch methods to prepare callback --- vendor/plugins/monkey_patches/attachment_fu/init.rb | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/vendor/plugins/monkey_patches/attachment_fu/init.rb b/vendor/plugins/monkey_patches/attachment_fu/init.rb index dcdf7c3..095ca59 100644 --- a/vendor/plugins/monkey_patches/attachment_fu/init.rb +++ b/vendor/plugins/monkey_patches/attachment_fu/init.rb @@ -3,26 +3,27 @@ require_dependency 'technoweenie/attachment_fu' -Technoweenie::AttachmentFu::InstanceMethods.module_eval do - def thumbnailable? - image? && !is_thumbnail? - end +ActionDispatch::Reloader.to_prepare do + Technoweenie::AttachmentFu::InstanceMethods.module_eval do + def thumbnailable? + image? && !is_thumbnail? + end - def is_thumbnail? - (thumbnail_class == self.class) && !(respond_to?(:parent_id) && parent_id.nil?) + def is_thumbnail? + (thumbnail_class == self.class) && !(respond_to?(:parent_id) && parent_id.nil?) + end end -end -# Monkey patch to rewrite attachment_fu's logic where no image with parent can -# be thumbnailable and supposition that full_filename will return a String -# while it might return Pathname. -Technoweenie::AttachmentFu::Backends::FileSystemBackend.module_eval do - def attachment_path_id - (is_thumbnail? && respond_to?(:parent_id)) ? parent_id : id - end + # Monkey patch to rewrite attachment_fu's logic where no image with parent can + # be thumbnailable and supposition that full_filename will return a String + # while it might return Pathname. + Technoweenie::AttachmentFu::Backends::FileSystemBackend.module_eval do + def attachment_path_id + (is_thumbnail? && respond_to?(:parent_id)) ? parent_id : id + end - def public_filename(thumbnail = nil) - full_filename(thumbnail).to_s.gsub %r(^#{Regexp.escape(base_path)}), '' + def public_filename(thumbnail = nil) + full_filename(thumbnail).to_s.gsub %r(^#{Regexp.escape(base_path)}), '' + end end end - -- libgit2 0.21.2