Class: Axn::Core::Flow::Handlers::Descriptors::MessageDescriptor
- Inherits:
-
BaseDescriptor
- Object
- BaseDescriptor
- Axn::Core::Flow::Handlers::Descriptors::MessageDescriptor
- Defined in:
- lib/axn/core/flow/handlers/descriptors/message_descriptor.rb
Overview
Data structure for message configuration - no behavior, just data
Instance Attribute Summary collapse
-
#join ⇒ Object
readonly
Returns the value of attribute join.
Attributes inherited from BaseDescriptor
Class Method Summary collapse
- .build(handler: nil, if: nil, unless: nil, standalone: nil, join: nil, **unsupported) ⇒ Object
-
.reject_unsupported_options!(options) ⇒ Object
Raise for any unknown option rather than silently dropping it.
Instance Method Summary collapse
-
#initialize(matcher:, handler:, standalone: false, join: nil) ⇒ MessageDescriptor
constructor
A new instance of MessageDescriptor.
- #standalone? ⇒ Boolean
Methods inherited from BaseDescriptor
Constructor Details
#initialize(matcher:, handler:, standalone: false, join: nil) ⇒ MessageDescriptor
Returns a new instance of MessageDescriptor.
14 15 16 17 18 |
# File 'lib/axn/core/flow/handlers/descriptors/message_descriptor.rb', line 14 def initialize(matcher:, handler:, standalone: false, join: nil) @standalone = standalone @join = join super(matcher:, handler:) end |
Instance Attribute Details
#join ⇒ Object (readonly)
Returns the value of attribute join.
12 13 14 |
# File 'lib/axn/core/flow/handlers/descriptors/message_descriptor.rb', line 12 def join @join end |
Class Method Details
.build(handler: nil, if: nil, unless: nil, standalone: nil, join: nil, **unsupported) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/axn/core/flow/handlers/descriptors/message_descriptor.rb', line 32 def self.build(handler: nil, if: nil, unless: nil, standalone: nil, join: nil, **unsupported) (unsupported) matcher = Matcher.build(if:, unless:) # Default by conditionality: an unconditional entry is the standalone base headline; a # conditional entry is an attached reason. standalone: false on an unconditional entry # promotes it into an attached reason (renders under the base); standalone: true on a # conditional reason opts it out (renders on its own). standalone = matcher.static? if standalone.nil? # join: combines the base with its reasons, so it only belongs on the base — an # unconditional, standalone headline. A reason (conditional, or a promoted standalone:false # entry) is rejected rather than silently ignored. base = matcher.static? && standalone raise ArgumentError, "join: only applies to the base (an unconditional headline)" if !join.nil? && !base raise ArgumentError, "join: must be a String or a callable ->(base, reason) {}" if !join.nil? && !(join.is_a?(String) || join.respond_to?(:call)) new(handler:, standalone:, join:, matcher:) end |
.reject_unsupported_options!(options) ⇒ Object
Raise for any unknown option rather than silently dropping it. Surface ALL unknown keys at once so the caller fixes them in one pass rather than one error at a time.
24 25 26 27 28 29 30 |
# File 'lib/axn/core/flow/handlers/descriptors/message_descriptor.rb', line 24 def self.() return if .empty? keys = .keys.map(&:inspect).join(", ") label = .size == 1 ? "Unknown #{keys} option" : "Unknown options #{keys}" raise ArgumentError, "#{label} for error/success message" end |
Instance Method Details
#standalone? ⇒ Boolean
20 |
# File 'lib/axn/core/flow/handlers/descriptors/message_descriptor.rb', line 20 def standalone? = @standalone |