Class: Macros::Error::SetFromContract

Inherits:
Base
  • Object
show all
Defined in:
lib/macros/error/set_from_contract.rb

Overview

Set error messages in the context using contract errors

Examples:

step Macros::Error::SetFromContract

Instance Method Summary collapse

Methods inherited from Base

#initialize, register

Constructor Details

This class inherits a constructor from Macros::Base

Instance Method Details

#call(ctx) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/macros/error/set_from_contract.rb', line 10

def call(ctx, **)
  error_messages = ctx['contract.default']&.errors&.messages
  return false unless error_messages

  ctx[:error_messages] = error_messages
  !!ctx[:error_messages]
end