Module: Papercrop::ActiveRecordExtension::InstanceMethods
- Defined in:
- lib/papercrop/active_record_extension.rb
Instance Method Summary collapse
-
#cropping?(attachment_name) ⇒ Boolean
Asks if the attachment received a crop process.
-
#image_geometry(attachment_name, style = :original) ⇒ Object
Returns a Paperclip::Geometry object from a named attachment.
-
#method_missing(method, *args) ⇒ Object
Uses method missing to reprocess the attachment callback.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
Uses method missing to reprocess the attachment callback
69 70 71 72 73 74 75 76 77 |
# File 'lib/papercrop/active_record_extension.rb', line 69 def method_missing(method, *args) if method.to_s =~ /(reprocess_to_crop_)(\S{1,})(_attachment)/ ( method.to_s.scan(/(reprocess_to_crop_)(\S{1,})(_attachment)/).flatten.second.to_sym ) else super end end |
Instance Method Details
#cropping?(attachment_name) ⇒ Boolean
Asks if the attachment received a crop process
49 50 51 52 53 54 |
# File 'lib/papercrop/active_record_extension.rb', line 49 def cropping?() !self.send(:"#{}_crop_x").blank? && !self.send(:"#{}_crop_y").blank? && !self.send(:"#{}_crop_w").blank? && !self.send(:"#{}_crop_h").blank? end |
#image_geometry(attachment_name, style = :original) ⇒ Object
Returns a Paperclip::Geometry object from a named attachment
62 63 64 65 |
# File 'lib/papercrop/active_record_extension.rb', line 62 def image_geometry(, style = :original) @geometry ||= {} @geometry[style] ||= Paperclip::Geometry.from_file(self.send().path(style)) end |