Sha256: c489659ba26e14db765cee444ef95014bd79b96cc85b27049723e99d600fa56c

Contents?: true

Size: 494 Bytes

Versions: 1

Compression:

Stored size: 494 Bytes

Contents

class ActiveRecord::Base
  def self.is_image_cropped(*attr_names)
    before_save :process_cropped_images

    define_method 'process_cropped_images' do
      attr_names.each do |attr|
        if eval("self.#{attr}")
          image = Paperclip.io_adapters.for(eval("self.#{attr}"))
          image.original_filename = "cropped_file_#{Time.now.to_f.to_s.gsub('.','')}.#{self.picture_content_type.split('/').last}"
          eval("self.#{attr} = image")
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
image-crop-0.1.1 lib/image/crop/is_image_cropped.rb