Class: MembershipCompJob

Inherits:
Struct
  • Object
show all
Defined in:
app/models/membership_comp_job.rb

Constant Summary collapse

QUEUE =
"comp"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#membership_compObject

Returns the value of attribute membership_comp

Returns:

  • (Object)

    the current value of membership_comp



1
2
3
# File 'app/models/membership_comp_job.rb', line 1

def membership_comp
  @membership_comp
end

Class Method Details

.enqueue(membership_comp) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/models/membership_comp_job.rb', line 4

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

.run_now?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'app/models/membership_comp_job.rb', line 24

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

Instance Method Details

#performObject



28
29
30
# File 'app/models/membership_comp_job.rb', line 28

def perform
  membership_comp.perform
end