Sha256: e16830aac1ddbc4c8490e5f303ce74658b58446599ce5ebad73d4d1b7b826bfd

Contents?: true

Size: 836 Bytes

Versions: 12

Compression:

Stored size: 836 Bytes

Contents

def obtain_class
  class_name = ENV['CLASS'] || ENV['class']
  raise "Deve especificar CLASS" unless class_name
  @klass = Object.const_get(class_name)
end

def obtain_after
  after = ENV['AFTER'] || ENV['after']
  @after = after ? eval(after) : nil
end

namespace :mailee do
  desc <<-DESC
Sincroniza os items da tabela CLASS com os contatos do Mailee.
Você pode também especificar o env AFTER para enviar apenas os contatos atualizados após uma data.
E.g. rake mailee:send CLASS=Contact AFTER=1.day.
  DESC
  task :send => :environment do
    klass = obtain_class
    after = obtain_after
    raise "A classe #{klass.name} deve ser sincronizada com o Mailee. Adicione o código 'sync_with_mailee'" if ! klass.syncd?
    print "Enviando\n"
    klass.send_all_to_mailee(after) do
      print "."
      STDOUT.flush
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
mailee-0.6.3 tasks/mailee_tasks.rake
mailee-0.6.2 tasks/mailee_tasks.rake
mailee-0.6.1 tasks/mailee_tasks.rake
mailee-0.6.0 tasks/mailee_tasks.rake
mailee-0.5.0 tasks/mailee_tasks.rake
mailee-0.4.3 tasks/mailee_tasks.rake
mailee-0.4.2 tasks/mailee_tasks.rake
mailee-0.3.0 tasks/mailee_tasks.rake
mailee-0.2.1 tasks/mailee_tasks.rake
mailee-0.2.0 tasks/mailee_tasks.rake
mailee-0.1.2 tasks/mailee_tasks.rake
mailee-0.1.0 tasks/mailee_tasks.rake