Class: Paperdragon::Paperclip::Model::Proxy

Inherits:
Object
  • Object
show all
Defined in:
lib/paperdragon/paperclip/model.rb

Overview

Needed to expose Paperclip’s DSL, like avatar.image.url(:thumb).

Instance Method Summary collapse

Constructor Details

#initialize(model, attachment_class) ⇒ Proxy

Returns a new instance of Proxy.



26
27
28
# File 'lib/paperdragon/paperclip/model.rb', line 26

def initialize(model, attachment_class)
  @attachment = attachment_class.new(model., {:model => model})
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



34
35
36
# File 'lib/paperdragon/paperclip/model.rb', line 34

def method_missing(name, *args, &block)
  @attachment.send(name, *args, &block)
end

Instance Method Details

#url(style) ⇒ Object



30
31
32
# File 'lib/paperdragon/paperclip/model.rb', line 30

def url(style)
  @attachment[style].url # Avatar::Photo.new(avatar, :thumb).url
end