Sha256: 82f222f8cf1ff016b61192bd81af30ae65525ce14a0356a70d8c40905d3224e4

Contents?: true

Size: 807 Bytes

Versions: 5

Compression:

Stored size: 807 Bytes

Contents

module Attachs
  module Task
    def self.process(force)
      model = (ENV['class'] || ENV['CLASS']).classify.constantize
      attachment = (ENV['attachment'] || ENV['ATTACHMENT']).to_sym
      model.find_each do |record|
        model.attachments.each do |attr, options|
          if attr == attachment
            record.send(attr).process(force)
          end
        end
      end
    end
  end
end

namespace :attachs do
  namespace :refresh do
    desc 'Refreshs all styles.'
    task all: :environment do
      Attachs::Task.process true
      Rails.logger.info 'All styles regenerated successfully.'
    end
    desc 'Refreshs missing styles.'
    task missing: :environment do
      Attachs::Task.process false
      Rails.logger.info 'Missing styles regenerated successfully.'
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
attachs-0.4.5 lib/tasks/attachs.rake
attachs-0.4.4 lib/tasks/attachs.rake
attachs-0.4.3 lib/tasks/attachs.rake
attachs-0.4.2 lib/tasks/attachs.rake
attachs-0.4.1 lib/tasks/attachs.rake