Method: Paperclip.missing_attachments_styles

Defined in:
lib/paperclip/missing_attachment_styles.rb

.missing_attachments_stylesObject

Returns hash with styles missing from recent run of rake paperclip:refresh:missing_styles

{
  :User => {:avatar => [:big]},
  :Book => {
    :cover => [:croppable]},
  }
}
[View source] [View on GitHub]

59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/paperclip/missing_attachment_styles.rb', line 59

def self.missing_attachments_styles
  current_styles = current_attachments_styles
  registered_styles = get_registered_attachments_styles

  Hash.new.tap do |missing_styles|
    current_styles.each do |klass, attachment_definitions|
      attachment_definitions.each do |attachment_name, styles|
        registered = registered_styles[klass][attachment_name] || [] rescue []
        missed = styles - registered
        if missed.present?
          klass_sym = klass.to_s.to_sym
          missing_styles[klass_sym] ||= Hash.new
          missing_styles[klass_sym][attachment_name.to_sym] ||= Array.new
          missing_styles[klass_sym][attachment_name.to_sym].concat(missed.to_a)
          missing_styles[klass_sym][attachment_name.to_sym].map!(&:to_s).sort!.map!(&:to_sym).uniq!
        end
      end
    end
  end
end