Module: Paperdragon::Paperclip::Model::ClassMethods

Defined in:
lib/paperdragon/paperclip/model.rb

Instance Method Summary collapse

Instance Method Details

#processable(name, attachment_class) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/paperdragon/paperclip/model.rb', line 10

def processable(name, attachment_class)
  # this overrides #image (or whatever the name is) from Paperclip::Model::processable.
  # This allows using both paperclip's `image.url(:thumb)` and the new paperdragon style
  # `image(:thumb).url`.
  mod = Module.new do # TODO: merge with attachment_accessor_for.
    define_method name do # e.g. Avatar#image
      Proxy.new(name, self, attachment_class)  # provide paperclip DSL.
    end
  end
  include mod
end