Created
July 10, 2009 18:03
-
-
Save enricob/144661 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 0d20e793a840c492b1305ccd48d90a7ff883aafc Mon Sep 17 00:00:00 2001 | |
From: Enrico Bianco <enricob@gmail.com> | |
Date: Fri, 10 Jul 2009 14:20:55 -0400 | |
Subject: [PATCH] have_attached_file_matcher receives an instance, not a class, as its subject. Implementation adjusted accordingly | |
--- | |
.../matchers/have_attached_file_matcher.rb | 10 +++++++--- | |
1 files changed, 7 insertions(+), 3 deletions(-) | |
diff --git a/lib/paperclip/matchers/have_attached_file_matcher.rb b/lib/paperclip/matchers/have_attached_file_matcher.rb | |
index 70348d9..f27048e 100644 | |
--- a/lib/paperclip/matchers/have_attached_file_matcher.rb | |
+++ b/lib/paperclip/matchers/have_attached_file_matcher.rb | |
@@ -28,20 +28,24 @@ module Paperclip | |
end | |
protected | |
+ | |
+ def subject_class | |
+ @subject.is_a?(Class) ? @subject : @subject.class | |
+ end | |
def responds? | |
- methods = @subject.instance_methods.map(&:to_s) | |
+ methods = subject_class.instance_methods.map(&:to_s) | |
methods.include?("#{@attachment_name}") && | |
methods.include?("#{@attachment_name}=") && | |
methods.include?("#{@attachment_name}?") | |
end | |
def has_column? | |
- @subject.column_names.include?("#{@attachment_name}_file_name") | |
+ subject_class.column_names.include?("#{@attachment_name}_file_name") | |
end | |
def included? | |
- @subject.ancestors.include?(Paperclip::InstanceMethods) | |
+ subject_class.ancestors.include?(Paperclip::InstanceMethods) | |
end | |
end | |
end | |
-- | |
1.6.0.2 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment