Class: LittleGhost::Runtime::Hooks::Artifacts::InterjectionContext

Inherits:
Data
  • Object
show all
Defined in:
lib/little_ghost/runtime/hooks/artifacts.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cancellation_tokenObject (readonly)

Returns the value of attribute cancellation_token

Returns:

  • (Object)

    the current value of cancellation_token



17
18
19
# File 'lib/little_ghost/runtime/hooks/artifacts.rb', line 17

def cancellation_token
  @cancellation_token
end

#deadlineObject (readonly)

Returns the value of attribute deadline

Returns:

  • (Object)

    the current value of deadline



17
18
19
# File 'lib/little_ghost/runtime/hooks/artifacts.rb', line 17

def deadline
  @deadline
end

#run_contextObject (readonly)

Returns the value of attribute run_context

Returns:

  • (Object)

    the current value of run_context



17
18
19
# File 'lib/little_ghost/runtime/hooks/artifacts.rb', line 17

def run_context
  @run_context
end

Instance Method Details

#artifact_control_valuesObject



24
25
26
27
28
29
# File 'lib/little_ghost/runtime/hooks/artifacts.rb', line 24

def artifact_control_values
  {
    cancellation_tokens: [run_context.cancellation_token, cancellation_token].compact,
    deadlines: [run_context.deadline, deadline].compact
  }
end

#check!Object



18
19
20
21
22
# File 'lib/little_ghost/runtime/hooks/artifacts.rb', line 18

def check!
  run_context.check!
  cancellation_token&.raise_if_cancelled!
  raise DeadlineExceededError, "The run deadline was reached" if deadline && Time.now >= deadline
end