module Card::Director::EventDelay

methods for handling delayed events

Public Instance Methods

contextualize_delayed_event(act_id, card, env, auth) { || ... } click to toggle source

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)

# File lib/card/director/event_delay.rb, line 11
def contextualize_delayed_event act_id, card, env, auth, &block
  return yield unless delaying?

  with_env_and_auth env, auth do
    with_delay_act(act_id, card, &block)
  end
end
delaying?() click to toggle source
# File lib/card/director/event_delay.rb, line 19
def delaying?
  Cardio.config.delaying == true
end
run_job_with_act(act, card, &block) click to toggle source
# 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) { || ... } click to toggle source
# 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, &block) click to toggle source
# File lib/card/director/event_delay.rb, line 35
def with_env_and_auth env, auth, &block
  Card::Auth.with auth do
    Card::Env.with env, &block
  end
end