Module: Igniter::Contracts::Execution::StructuredDump
- Defined in:
- lib/igniter/contracts/execution/structured_dump.rb
Class Method Summary collapse
- .dump(value) ⇒ Object
- .dump_object(value) ⇒ Object
- .normalize_key(key) ⇒ Object
- .serializable_contract_object?(value) ⇒ Boolean
Class Method Details
.dump(value) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/igniter/contracts/execution/structured_dump.rb', line 9 def dump(value) case value when Array value.map { |entry| dump(entry) } when Hash value.to_h { |key, entry| [normalize_key(key), dump(entry)] } else dump_object(value) end end |
.dump_object(value) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/igniter/contracts/execution/structured_dump.rb', line 20 def dump_object(value) if serializable_contract_object?(value) value.to_h else value end end |
.normalize_key(key) ⇒ Object
43 44 45 |
# File 'lib/igniter/contracts/execution/structured_dump.rb', line 43 def normalize_key(key) key.respond_to?(:to_sym) ? key.to_sym : key end |
.serializable_contract_object?(value) ⇒ Boolean
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/igniter/contracts/execution/structured_dump.rb', line 28 def serializable_contract_object?(value) value.is_a?(NamedValues) || value.is_a?(Operation) || value.is_a?(CompiledGraph) || value.is_a?(ExecutionResult) || value.is_a?(EffectInvocation) || value.is_a?(ExecutionRequest) || value.is_a?(DiagnosticsSection) || value.is_a?(DiagnosticsReport) || value.is_a?(ValidationFinding) || value.is_a?(ValidationReport) || value.is_a?(CompilationReport) || (defined?(StepResult) && value.is_a?(StepResult)) end |