class Paperclip::AttachmentRegistry
Public Class Methods
clear()
click to toggle source
# File lib/paperclip/attachment_registry.rb, line 11 def self.clear instance.clear end
definitions_for(klass)
click to toggle source
# File lib/paperclip/attachment_registry.rb, line 23 def self.definitions_for(klass) instance.definitions_for(klass) end
each_definition(&block)
click to toggle source
# File lib/paperclip/attachment_registry.rb, line 19 def self.each_definition(&block) instance.each_definition(&block) end
names_for(klass)
click to toggle source
# File lib/paperclip/attachment_registry.rb, line 15 def self.names_for(klass) instance.names_for(klass) end
new()
click to toggle source
# File lib/paperclip/attachment_registry.rb, line 27 def initialize clear end
register(klass, attachment_name, attachment_options)
click to toggle source
# File lib/paperclip/attachment_registry.rb, line 7 def self.register(klass, attachment_name, attachment_options) instance.register(klass, attachment_name, attachment_options) end
Public Instance Methods
clear()
click to toggle source
# File lib/paperclip/attachment_registry.rb, line 37 def clear @attachments = Hash.new { |h, k| h[k] = {} } end
definitions_for(klass)
click to toggle source
# File lib/paperclip/attachment_registry.rb, line 53 def definitions_for(klass) parent_classes = klass.ancestors.reverse parent_classes.each_with_object({}) do |ancestor, inherited_definitions| inherited_definitions.deep_merge! @attachments[ancestor] end end
each_definition() { |klass, name, options| ... }
click to toggle source
# File lib/paperclip/attachment_registry.rb, line 45 def each_definition @attachments.each do |klass, attachments| attachments.each do |name, options| yield klass, name, options end end end
names_for(klass)
click to toggle source
# File lib/paperclip/attachment_registry.rb, line 41 def names_for(klass) @attachments[klass].keys end
register(klass, attachment_name, attachment_options)
click to toggle source
# File lib/paperclip/attachment_registry.rb, line 31 def register(klass, attachment_name, attachment_options) @attachments ||= {} @attachments[klass] ||= {} @attachments[klass][attachment_name] = attachment_options end