Class: Polypaperclip::Attachment
- Inherits:
-
Paperclip::Attachment
- Object
- Paperclip::Attachment
- Polypaperclip::Attachment
- Defined in:
- lib/polypaperclip/attachment.rb
Instance Method Summary collapse
- #assign(uploaded_file) ⇒ Object
-
#initialize(name, instance, options = {}) ⇒ Attachment
constructor
A new instance of Attachment.
- #instance_read(attr) ⇒ Object
Constructor Details
#initialize(name, instance, options = {}) ⇒ Attachment
Returns a new instance of Attachment.
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/polypaperclip/attachment.rb', line 4 def initialize(name, instance, = {}) super #retain the actual object in the attachment instance @poly_instance = instance @poly_name = name #cheat instance to reflect the polymorphic attachment #this sort of tricks paperclip in order for it to the right things @instance = instance.send("#{name}_attachment") @name = "attachment" end |
Instance Method Details
#assign(uploaded_file) ⇒ Object
17 18 19 20 |
# File 'lib/polypaperclip/attachment.rb', line 17 def assign(uploaded_file) build_instance if @instance.nil? #we want to replace super end |
#instance_read(attr) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/polypaperclip/attachment.rb', line 22 def instance_read(attr) if @instance.nil? nil else super end end |