Class: RubyReactor::Skipped

Inherits:
Success
  • Object
show all
Defined in:
lib/ruby_reactor.rb

Overview

Marks a single step as skipped while the reactor continues. Behaves exactly like Success — the value flows to dependants via result(:step) — except skipped? is true and the step is not enrolled for rollback (nothing happened, so there is nothing to undo).

Instance Attribute Summary collapse

Attributes inherited from Success

#value

Instance Method Summary collapse

Methods inherited from Success

#failure?, #halted?, #success?, #to_h

Constructor Details

#initialize(value = UNSET, reason: nil, step_name: nil) ⇒ Skipped

Returns a new instance of Skipped.



117
118
119
120
121
122
123
124
125
126
127
# File 'lib/ruby_reactor.rb', line 117

def initialize(value = UNSET, reason: nil, step_name: nil)
  if value.equal?(UNSET) && !reason.nil?
    raise ArgumentError,
          "RubyReactor::Skipped now marks a single step as skipped and continues. " \
          "The clean halt you want is RubyReactor.Halt(reason: ...) / halt!(reason: ...)."
  end

  super(value.equal?(UNSET) ? nil : value)
  @reason = reason
  @step_name = step_name
end

Instance Attribute Details

#reasonObject (readonly)

Returns the value of attribute reason.



115
116
117
# File 'lib/ruby_reactor.rb', line 115

def reason
  @reason
end

#step_nameObject (readonly)

Returns the value of attribute step_name.



115
116
117
# File 'lib/ruby_reactor.rb', line 115

def step_name
  @step_name
end

Instance Method Details

#skipped?Boolean

Returns:



129
130
131
# File 'lib/ruby_reactor.rb', line 129

def skipped?
  true
end