Class: Smith::Workflow::PreparedStepExecutionAuthorization

Inherits:
Object
  • Object
show all
Defined in:
lib/smith/workflow/prepared_step_execution_authorization.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prepared_step:, dispatch_claim:, execution_bindings:) ⇒ PreparedStepExecutionAuthorization

Returns a new instance of PreparedStepExecutionAuthorization.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/smith/workflow/prepared_step_execution_authorization.rb', line 14

def initialize(prepared_step:, dispatch_claim:, execution_bindings:)
  unless prepared_step.is_a?(PreparedStep)
    raise ArgumentError, "prepared_step must be a Smith::Workflow::PreparedStep"
  end
  unless dispatch_claim.nil? || dispatch_claim.is_a?(PreparedStepDispatch)
    raise ArgumentError, "dispatch_claim must be a Smith::Workflow::PreparedStepDispatch or nil"
  end
  if dispatch_claim && dispatch_claim.prepared_step.to_h != prepared_step.to_h
    raise ArgumentError, "dispatch claim must belong to the prepared step"
  end
  unless execution_bindings.is_a?(SplitStepPersistence::ExecutionBindingSnapshot)
    raise ArgumentError, "execution_bindings must be a Smith execution binding snapshot"
  end

  @prepared_step = prepared_step
  @dispatch_claim = dispatch_claim
  @execution_bindings = execution_bindings
  @execution_scope = PreparedStepExecutionScope.new
  @process_id = Process.pid
  freeze
end

Instance Attribute Details

#dispatch_claimObject (readonly)

Returns the value of attribute dispatch_claim.



12
13
14
# File 'lib/smith/workflow/prepared_step_execution_authorization.rb', line 12

def dispatch_claim
  @dispatch_claim
end

#prepared_stepObject (readonly)

Returns the value of attribute prepared_step.



12
13
14
# File 'lib/smith/workflow/prepared_step_execution_authorization.rb', line 12

def prepared_step
  @prepared_step
end

Instance Method Details

#_dump(_depth) ⇒ Object

Raises:

  • (TypeError)


65
66
67
# File 'lib/smith/workflow/prepared_step_execution_authorization.rb', line 65

def _dump(_depth)
  raise TypeError, "prepared-step execution authorizations cannot be serialized"
end

#active_in_current_execution?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/smith/workflow/prepared_step_execution_authorization.rb', line 57

def active_in_current_execution?
  issued_in_current_process? && @execution_scope.active_for?(Thread.current)
end

#as_jsonObject

Raises:

  • (TypeError)


77
78
79
# File 'lib/smith/workflow/prepared_step_execution_authorization.rb', line 77

def as_json(*)
  raise TypeError, "prepared-step execution authorizations cannot be serialized"
end

#each_agent_binding(&block) ⇒ Object

Raises:

  • (ArgumentError)


44
45
46
47
48
49
50
# File 'lib/smith/workflow/prepared_step_execution_authorization.rb', line 44

def each_agent_binding(&block)
  ensure_binding_access!
  raise ArgumentError, "a block is required to inspect captured agent bindings" unless block

  @execution_bindings.each_agent_binding(&block)
  self
end

#encode_with(_coder) ⇒ Object

Raises:

  • (TypeError)


69
70
71
# File 'lib/smith/workflow/prepared_step_execution_authorization.rb', line 69

def encode_with(_coder)
  raise TypeError, "prepared-step execution authorizations cannot be serialized"
end

#fetch_agent!Object



38
39
40
41
42
# File 'lib/smith/workflow/prepared_step_execution_authorization.rb', line 38

def fetch_agent!(...)
  ensure_binding_access!

  @execution_bindings.fetch!(...)
end

#init_with(_coder) ⇒ Object

Raises:

  • (TypeError)


73
74
75
# File 'lib/smith/workflow/prepared_step_execution_authorization.rb', line 73

def init_with(_coder)
  raise TypeError, "prepared-step execution authorizations cannot be deserialized"
end

#initialize_copy(_source) ⇒ Object

Raises:

  • (TypeError)


61
62
63
# File 'lib/smith/workflow/prepared_step_execution_authorization.rb', line 61

def initialize_copy(_source)
  raise TypeError, "prepared-step execution authorizations cannot be copied"
end

#issued_in_current_process?Boolean

Returns:

  • (Boolean)


36
# File 'lib/smith/workflow/prepared_step_execution_authorization.rb', line 36

def issued_in_current_process? = @process_id == Process.pid

#to_jsonObject

Raises:

  • (TypeError)


81
82
83
# File 'lib/smith/workflow/prepared_step_execution_authorization.rb', line 81

def to_json(*)
  raise TypeError, "prepared-step execution authorizations cannot be serialized"
end

#verify_workflow!(workflow_class) ⇒ Object



52
53
54
55
# File 'lib/smith/workflow/prepared_step_execution_authorization.rb', line 52

def verify_workflow!(workflow_class)
  ensure_active_execution!
  @execution_bindings.verify_workflow!(workflow_class)
end