Commit 525b2968 by Pavel Forkert Committed by Jon Yurek

Allowed to refresh images of classes with namespaces (fixes).

parent 12bc18d2
...@@ -114,7 +114,7 @@ module Paperclip ...@@ -114,7 +114,7 @@ module Paperclip
end end
def each_instance_with_attachment(klass, name) def each_instance_with_attachment(klass, name)
Object.const_get(klass).all.each do |instance| obtain_class_from_class_name(klass).all.each do |instance|
yield(instance) if instance.send(:"#{name}?") yield(instance) if instance.send(:"#{name}?")
end end
end end
...@@ -132,6 +132,12 @@ module Paperclip ...@@ -132,6 +132,12 @@ module Paperclip
def logging? #:nodoc: def logging? #:nodoc:
options[:log] options[:log]
end end
def obtain_class_from_class_name(class_name)
class_name.split('::').inject(Object) do |klass, partial_class_name|
klass.const_get(partial_class_name)
end
end
end end
class PaperclipError < StandardError #:nodoc: class PaperclipError < StandardError #:nodoc:
......
...@@ -4,14 +4,8 @@ def obtain_class ...@@ -4,14 +4,8 @@ def obtain_class
class_name class_name
end end
def obtain_class_from_class_name(class_name)
class_name.split('::').inject(Object) do |klass, partial_class_name|
klass.const_get(partial_class_name)
end
end
def obtain_attachments(klass) def obtain_attachments(klass)
klass = obtain_class_from_class_name(klass.to_s) klass = Paperclip.obtain_class_from_class_name(klass.to_s)
name = ENV['ATTACHMENT'] || ENV['attachment'] name = ENV['ATTACHMENT'] || ENV['attachment']
raise "Class #{klass.name} has no attachments specified" unless klass.respond_to?(:attachment_definitions) raise "Class #{klass.name} has no attachments specified" unless klass.respond_to?(:attachment_definitions)
if !name.blank? && klass.attachment_definitions.keys.include?(name) if !name.blank? && klass.attachment_definitions.keys.include?(name)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment