Class: Axn::Core::Context
- Inherits:
-
Object
- Object
- Axn::Core::Context
- Defined in:
- lib/axn/core/context.rb
Instance Attribute Summary collapse
-
#elapsed_time ⇒ Object
readonly
Framework field accessors.
-
#exception ⇒ Object
readonly
Returns the value of attribute exception.
-
#exposed_data ⇒ Object
Framework field accessors.
-
#provided_data ⇒ Object
Framework field accessors.
Instance Method Summary collapse
- #__classified_as_failure? ⇒ Boolean
-
#__classify_as_failure! ⇒ Object
Recorded by the executor when an exception settles as a failure (a
fail!, afails_onmatch, or a nestedfails_onmade sticky) rather than an unhandled exception. -
#__combined_data ⇒ Object
INTERNAL: base for further filtering (for logging) or providing user with usage hints.
- #__early_completion? ⇒ Boolean
- #__early_completion_message ⇒ Object
- #__early_completion_standalone ⇒ Object
- #__finalize! ⇒ Object
- #__record_early_completion(message, standalone: false) ⇒ Object
- #__record_exception(e) ⇒ Object
- #failed? ⇒ Boolean
- #finalized? ⇒ Boolean
-
#initialize(**provided_data) ⇒ Context
constructor
A new instance of Context.
-
#ok? ⇒ Boolean
Framework state methods.
Constructor Details
#initialize(**provided_data) ⇒ Context
Returns a new instance of Context.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/axn/core/context.rb', line 6 def initialize(**provided_data) # Normalize inbound keys to symbols so the read path has indifferent access: a declared field's # key (always symbolized at declaration) matches the call-arg key regardless of how the caller # spelled it. Splatting JSON/HTTP params straight into `.call(**body)` (string keys) Just Works # instead of silently reading nil. Top-level keys only — values (including nested hashes) are # untouched. Async deserialize paths already re-symbolize keys before re-invoking, so this is # consistent with the round-trip (see Axn::Async serialization). See PRO-2790. @provided_data = provided_data.transform_keys(&:to_sym) @exposed_data = {} # Framework-managed fields @failure = false @exception = nil @elapsed_time = nil @early_completion_standalone = false end |
Instance Attribute Details
#elapsed_time ⇒ Object
Framework field accessors
29 30 31 |
# File 'lib/axn/core/context.rb', line 29 def elapsed_time @elapsed_time end |
#exception ⇒ Object (readonly)
Returns the value of attribute exception.
30 31 32 |
# File 'lib/axn/core/context.rb', line 30 def exception @exception end |
#exposed_data ⇒ Object
Framework field accessors
29 30 31 |
# File 'lib/axn/core/context.rb', line 29 def exposed_data @exposed_data end |
#provided_data ⇒ Object
Framework field accessors
29 30 31 |
# File 'lib/axn/core/context.rb', line 29 def provided_data @provided_data end |
Instance Method Details
#__classified_as_failure? ⇒ Boolean
52 |
# File 'lib/axn/core/context.rb', line 52 def __classified_as_failure? = @classified_as_failure || false |
#__classify_as_failure! ⇒ Object
Recorded by the executor when an exception settles as a failure (a fail!, a fails_on match,
or a nested fails_on made sticky) rather than an unhandled exception. result.outcome reads this
so the failure/exception distinction survives after the per-execution classification set is cleared.
51 |
# File 'lib/axn/core/context.rb', line 51 def __classify_as_failure! = @classified_as_failure = true |
#__combined_data ⇒ Object
INTERNAL: base for further filtering (for logging) or providing user with usage hints
38 |
# File 'lib/axn/core/context.rb', line 38 def __combined_data = @provided_data.merge(@exposed_data) |
#__early_completion? ⇒ Boolean
40 |
# File 'lib/axn/core/context.rb', line 40 def __early_completion? = @early_completion || false |
#__early_completion_message ⇒ Object
64 |
# File 'lib/axn/core/context.rb', line 64 def = @early_completion_message.presence |
#__early_completion_standalone ⇒ Object
65 |
# File 'lib/axn/core/context.rb', line 65 def __early_completion_standalone = @early_completion_standalone |
#__finalize! ⇒ Object
67 68 69 |
# File 'lib/axn/core/context.rb', line 67 def __finalize! @finalized = true end |
#__record_early_completion(message, standalone: false) ⇒ Object
54 55 56 57 58 59 60 61 62 |
# File 'lib/axn/core/context.rb', line 54 def __record_early_completion(, standalone: false) # Only store a real (non-sentinel) message, but always record the standalone opt-out so a bare # `done!(standalone: true)` isn't silently dropped (it's moot when no message resolves, but the # flag must reflect the call rather than retain the default). @early_completion_message = unless == Axn::Internal::EarlyCompletion.new. @early_completion_standalone = standalone @early_completion = true @finalized = true end |
#__record_exception(e) ⇒ Object
42 43 44 45 46 |
# File 'lib/axn/core/context.rb', line 42 def __record_exception(e) @exception = e @failure = true @finalized = true end |
#failed? ⇒ Boolean
25 |
# File 'lib/axn/core/context.rb', line 25 def failed? = @failure || false |
#finalized? ⇒ Boolean
26 |
# File 'lib/axn/core/context.rb', line 26 def finalized? = @finalized || false |
#ok? ⇒ Boolean
Framework state methods
24 |
# File 'lib/axn/core/context.rb', line 24 def ok? = !@failure |