Module: Hubbado::Sequence::Runner::Substitute

Includes:
RecordInvocation
Defined in:
lib/hubbado/sequence/runner.rb

Instance Method Summary collapse

Instance Method Details

#not_found(**error_attrs) ⇒ Object



131
132
133
# File 'lib/hubbado/sequence/runner.rb', line 131

def not_found(**error_attrs)
  configure_failure(:not_found, error_attrs)
end

#other_error(code:, **error_attrs) ⇒ Object



139
140
141
# File 'lib/hubbado/sequence/runner.rb', line 139

def other_error(code:, **error_attrs)
  configure_failure(code, error_attrs)
end

#policy_failure(**error_attrs) ⇒ Object



127
128
129
# File 'lib/hubbado/sequence/runner.rb', line 127

def policy_failure(**error_attrs)
  configure_failure(:forbidden, error_attrs)
end

#ran_with?(sequencer_class, **expected_kwargs) ⇒ Boolean

Returns:

  • (Boolean)


143
144
145
146
147
148
149
150
151
# File 'lib/hubbado/sequence/runner.rb', line 143

def ran_with?(sequencer_class, **expected_kwargs)
  records.any? do |invocation|
    next false unless invocation.method_name == :call
    next false unless invocation.arguments[:sequencer_class] == sequencer_class

    captured = invocation.arguments[:kwargs] || {}
    expected_kwargs.all? { |key, value| captured[key] == value }
  end
end

#succeed_with(**ctx_writes) ⇒ Object



122
123
124
125
# File 'lib/hubbado/sequence/runner.rb', line 122

def succeed_with(**ctx_writes)
  @configured_outcome = { kind: :success, ctx_writes: ctx_writes }
  self
end

#validation_failure(**error_attrs) ⇒ Object



135
136
137
# File 'lib/hubbado/sequence/runner.rb', line 135

def validation_failure(**error_attrs)
  configure_failure(:validation_failed, error_attrs)
end