Exception: Statecraft::MetadataRequired

Inherits:
Error
  • Object
show all
Defined in:
lib/statecraft/errors.rb

Overview

A question (can_fire?, may_?, available_) was asked without metadata while an input_guard stands on the consulted path — its answer without the input would be a false "no", so the question refuses loudly instead. An explicit metadata: {} states "my input is empty" and is legal.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(record:, question:, guards:) ⇒ MetadataRequired

Returns a new instance of MetadataRequired.



150
151
152
153
154
155
156
157
# File 'lib/statecraft/errors.rb', line 150

def initialize(record:, question:, guards:)
  @record = record
  @question = question
  @guards = guards
  super("#{question} on #{record.class.name} consults input guards " \
        "#{guards.map(&:inspect).join(", ")} — pass metadata: to answer with input " \
        "(an explicit metadata: {} means the input is empty)")
end

Instance Attribute Details

#guardsObject (readonly)

Returns the value of attribute guards.



148
149
150
# File 'lib/statecraft/errors.rb', line 148

def guards
  @guards
end

#questionObject (readonly)

Returns the value of attribute question.



148
149
150
# File 'lib/statecraft/errors.rb', line 148

def question
  @question
end

#recordObject (readonly)

Returns the value of attribute record.



148
149
150
# File 'lib/statecraft/errors.rb', line 148

def record
  @record
end