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



149
150
151
# File 'lib/hubbado/sequence/runner.rb', line 149

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

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



157
158
159
# File 'lib/hubbado/sequence/runner.rb', line 157

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

#policy_failure(**error_attrs) ⇒ Object



145
146
147
# File 'lib/hubbado/sequence/runner.rb', line 145

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

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

Returns:

  • (Boolean)


161
162
163
164
165
166
167
168
169
# File 'lib/hubbado/sequence/runner.rb', line 161

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



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

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

#validation_failure(**error_attrs) ⇒ Object



153
154
155
# File 'lib/hubbado/sequence/runner.rb', line 153

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