Class: Marshalsea::Marshal::BoundaryDetector::Decision

Inherits:
Object
  • Object
show all
Defined in:
lib/marshalsea/marshal/boundary_detector.rb

Constant Summary collapse

STATE_PROCEED =
:proceed
STATE_BLOCKED =
:blocked
STATE_OBSERVED =
:observed
STATES =
[STATE_PROCEED, STATE_BLOCKED, STATE_OBSERVED].freeze
STATE_PREDICATES =
%i[proceed? blocked? observed?].freeze
UNKNOWN_STATE =
"unknown decision state %p, expected one of %s"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(state:, reason: nil, snapshot: nil, result: nil) ⇒ Decision

Returns a new instance of Decision.

Raises:

  • (ArgumentError)


70
71
72
73
74
75
76
77
# File 'lib/marshalsea/marshal/boundary_detector.rb', line 70

def initialize(state:, reason: nil, snapshot: nil, result: nil)
  raise ArgumentError, format(UNKNOWN_STATE, state, STATES.join(", ")) unless STATES.include?(state)

  @state = state
  @reason = reason
  @snapshot = snapshot
  @result = result
end

Instance Attribute Details

#reasonObject (readonly)

Returns the value of attribute reason.



68
69
70
# File 'lib/marshalsea/marshal/boundary_detector.rb', line 68

def reason
  @reason
end

#resultObject (readonly)

Returns the value of attribute result.



68
69
70
# File 'lib/marshalsea/marshal/boundary_detector.rb', line 68

def result
  @result
end

#snapshotObject (readonly)

Returns the value of attribute snapshot.



68
69
70
# File 'lib/marshalsea/marshal/boundary_detector.rb', line 68

def snapshot
  @snapshot
end

#stateObject (readonly)

Returns the value of attribute state.



68
69
70
# File 'lib/marshalsea/marshal/boundary_detector.rb', line 68

def state
  @state
end

Instance Method Details

#blocked?Boolean

Returns:

  • (Boolean)


83
84
85
# File 'lib/marshalsea/marshal/boundary_detector.rb', line 83

def blocked?
  state == STATE_BLOCKED
end

#observed?Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/marshalsea/marshal/boundary_detector.rb', line 87

def observed?
  state == STATE_OBSERVED
end

#proceed?Boolean

Returns:

  • (Boolean)


79
80
81
# File 'lib/marshalsea/marshal/boundary_detector.rb', line 79

def proceed?
  state == STATE_PROCEED
end