Class: Boxcars::ConductResult
- Inherits:
-
Hash
- Object
- Hash
- Boxcars::ConductResult
- Defined in:
- lib/boxcars/conduct_result.rb
Overview
Hash-like result wrapper returned by ‘Boxcar#conduct`. Supports legacy `result.answer` access while guiding users toward `Boxcars::Result.extract(result)`.
Constant Summary collapse
- LEGACY_ANSWER_ACCESS_REMOVE_IN =
"3.0"
Class Attribute Summary collapse
-
.emit_legacy_answer_access_warnings ⇒ Object
Returns the value of attribute emit_legacy_answer_access_warnings.
Class Method Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#answer_result ⇒ Boxcars::Result?
Extract ‘Boxcars::Result` from conduct payload without triggering the legacy `[:answer]` deprecation warning.
- #fetch(key, *args) ⇒ Object
-
#initialize(hash = {}) ⇒ ConductResult
constructor
A new instance of ConductResult.
-
#output_for(key) ⇒ Object?
Read an output key from conduct payload without triggering deprecation warnings for legacy ‘[:answer]` hash access.
Constructor Details
#initialize(hash = {}) ⇒ ConductResult
Returns a new instance of ConductResult.
21 22 23 24 |
# File 'lib/boxcars/conduct_result.rb', line 21 def initialize(hash = {}) super() update(hash) end |
Class Attribute Details
.emit_legacy_answer_access_warnings ⇒ Object
Returns the value of attribute emit_legacy_answer_access_warnings.
13 14 15 |
# File 'lib/boxcars/conduct_result.rb', line 13 def emit_legacy_answer_access_warnings @emit_legacy_answer_access_warnings end |
Class Method Details
.reset_deprecation_warnings! ⇒ Object
15 16 17 |
# File 'lib/boxcars/conduct_result.rb', line 15 def reset_deprecation_warnings! @warned_legacy_answer_access = false end |
Instance Method Details
#[](key) ⇒ Object
26 27 28 29 |
# File 'lib/boxcars/conduct_result.rb', line 26 def [](key) warn_legacy_answer_access(key) super end |
#answer_result ⇒ Boxcars::Result?
Extract ‘Boxcars::Result` from conduct payload without triggering the legacy `[:answer]` deprecation warning.
39 40 41 42 43 44 45 46 47 |
# File 'lib/boxcars/conduct_result.rb', line 39 def answer_result candidate = if key?(:answer) hash_read(:answer) elsif key?("answer") hash_read("answer") end candidate if candidate.is_a?(Boxcars::Result) end |
#fetch(key, *args) ⇒ Object
31 32 33 34 |
# File 'lib/boxcars/conduct_result.rb', line 31 def fetch(key, *args, &) warn_legacy_answer_access(key) super end |
#output_for(key) ⇒ Object?
Read an output key from conduct payload without triggering deprecation warnings for legacy ‘[:answer]` hash access.
53 54 55 56 57 58 59 60 |
# File 'lib/boxcars/conduct_result.rb', line 53 def output_for(key) return hash_read(key) if key?(key) string_key = key.to_s return hash_read(string_key) if key?(string_key) nil end |