Sha256: c9154fd072d283998038077167c72bd0717d49717fb560f69c47510c4a5bf278

Contents?: true

Size: 788 Bytes

Versions: 10

Compression:

Stored size: 788 Bytes

Contents

class MembershipCompJob < Struct.new(:membership_comp)
  QUEUE = "comp"

  def self.enqueue(membership_comp)
    job = MembershipCompJob.new

    #
    # Weird Rails/DJ bug where calling validate on membership_comp caused the errors
    # to hang around. DJ would choke on when Syck tried to deserialize the errors attr
    # The error message was horrible and misleading (uninitialized constant Syck::Syck)
    #
    # It's probably because we're including ActiveModel::Validations on MembershipComp
    #
    membership_comp.clear_errors
    job.membership_comp = membership_comp

    if run_now?
      job.perform
    else
      Delayed::Job.enqueue job, :queue => QUEUE
    end
  end

  def self.run_now?
    Rails.env.test?
  end

  def perform
    membership_comp.perform
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
artfully_ose-1.2.0 app/models/membership_comp_job.rb
artfully_ose-1.2.0.beta.1 app/models/membership_comp_job.rb
artfully_ose-1.2.0.alpha.2 app/models/membership_comp_job.rb
artfully_ose-1.2.0.alpha.1 app/models/membership_comp_job.rb
artfully_ose-1.2.0.pre.27 app/models/membership_comp_job.rb
artfully_ose-1.2.0.pre.26 app/models/membership_comp_job.rb
artfully_ose-1.2.0.pre.24 app/models/membership_comp_job.rb
artfully_ose-1.2.0.pre.23 app/models/membership_comp_job.rb
artfully_ose-1.2.0.pre.21 app/models/membership_comp_job.rb
artfully_ose-1.2.0.pre.20 app/models/membership_comp_job.rb