Module: Card::Director::EventDelay

Included in:
Card::Director
Defined in:
lib/card/director/event_delay.rb

Overview

methods for handling delayed events

Instance Method Summary collapse

Instance Method Details

#contextualize_delayed_event(act_id, card, env, auth) ⇒ Object

If active jobs (and hence the integrate_with_delay events) don’t run in a background process then Card::Env.deserialize! decouples the controller’s params hash and the Card::Env’s params hash with the effect that params changes in the CardController get lost (a crucial example are success params that are processed in CardController#soft_redirect)



11
12
13
14
15
16
17
# File 'lib/card/director/event_delay.rb', line 11

def contextualize_delayed_event act_id, card, env, auth
  return yield unless delaying?

  with_env_and_auth env, auth do
    with_delay_act(act_id, card) { yield }
  end
end

#delaying?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/card/director/event_delay.rb', line 19

def delaying?
  Cardio.config.delaying == true
end

#run_job_with_act(act, card, &block) ⇒ Object



29
30
31
32
33
# File 'lib/card/director/event_delay.rb', line 29

def run_job_with_act act, card, &block
  run_act card do
    act_card.director.run_delayed_event act, &block
  end
end

#with_delay_act(act_id, card, &block) ⇒ Object



23
24
25
26
27
# File 'lib/card/director/event_delay.rb', line 23

def with_delay_act act_id, card, &block
  return yield unless act_id && (self.act = Act.find act_id)

  run_job_with_act act, card, &block
end

#with_env_and_auth(env, auth) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/card/director/event_delay.rb', line 35

def with_env_and_auth env, auth
  Card::Auth.with auth do
    Card::Env.with env do
      yield
    end
  end
end