Class: Retab::Types::BaseModel
- Inherits:
-
Object
- Object
- Retab::Types::BaseModel
show all
- Defined in:
- lib/retab/types/base_model.rb
Direct Known Subclasses
Actor, AllItemsMatchCondition, AnyItemMatchesCondition, ApiCallAttempt, ApiCallInvocation, ApproveReviewRequest, ArrayContainsCondition, ArtifactDrift, ArtifactFreshness, AssertionFailure, AssertionResult, AssertionSchemaDep, AssertionSpec, AwaitingReviewRun, AwaitingReviewStepLifecycle, BBox, BetweenCondition, BlockEvalBatchExecutionCounts, BlockEvalLifecycleCounts, BlockEvalOutcomeCounts, BlockExecFileHandleInput, BlockExecFileRef, BlockExecJsonHandleInput, CancelWorkflowExperimentRunResponse, CancelWorkflowRequest, CancelWorkflowResponse, CancelledBlockExecutionLifecycle, CancelledStepLifecycle, CancelledTerminal, Category, Classification, ClassificationConsensus, ClassificationDecision, ClassificationRequest, ClassificationWorkflowArtifact, CompleteFileUploadRequest, CompletedBlockExecutionLifecycle, ConditionEvaluationDetails, ConditionEvaluationPerItem, ConditionEvaluationResult, ConditionEvaluationSubCondition, ConditionalEvaluation, ContainCondition, ContainerContextData, CreateBlockExecutionRequest, CreateEditTemplateRequest, CreateExperimentRequest, CreateExperimentRunRequest, CreateFileBlueprintRequest, CreateReviewVersionRequest, CreateSecretRequest, CreateUploadResponse, CreateWorkflowEvalRequest, CreateWorkflowEvalRunRequest, CreateWorkflowRequest, CreateWorkflowRunRequest, CreateWorkflowTableUploadRequest, DeclarativeApplyResponse, DeclarativeExportResponse, DeclarativePlanChange, DeclarativePlanFieldChange, DeclarativePlanResourceChange, DeclarativePlanResponse, DeclarativePlanSummary, DeclarativeValidationResponse, DeclarativeWorkflowRequest, Edit, EditConfig, EditRequest, EditResult, EditTemplate, EditWorkflowArtifact, EndsWithCondition, EqualCondition, ErrorBlockExecutionLifecycle, ErrorDetails, ErrorStepLifecycle, ErrorTerminal, ErrorWorkflowEvalRun, EvalRunBlockTarget, EvalRunFreshness, EvalRunTrigger, ExistCondition, ExperimentByDocumentMetricsResponse, ExperimentByDocumentTargetMetric, ExperimentByTargetDocumentMetric, ExperimentByTargetMetricsResponse, ExperimentConfusionFlowMetric, ExperimentConfusionSummaryAggregate, ExperimentDocumentCaptureRequest, ExperimentDocumentProvenance, ExperimentExtractSummaryAggregate, ExperimentMetricDocumentRef, ExperimentMetricsMissingError, ExperimentMetricsStaleError, ExperimentResult, ExperimentResultTiming, ExperimentRun, ExperimentRunTiming, ExperimentRunTrigger, ExperimentSummaryMetricDocument, ExperimentSummaryMetricsResponse, ExperimentTargetConfusionMetric, ExperimentVoteRow, ExperimentVotesMetricsResponse, ExplicitExperimentDocumentRequest, Extraction, ExtractionConsensus, ExtractionRequest, ExtractionWorkflowArtifact, FileBlueprint, FileLink, FileModel, FormField, FunctionInvocation, GenerateSchemaRequest, HttpValidationError, JsonSchemaValidCondition, LatestBlockEvalRunSummary, LengthCompareCondition, LlmJudgedAsCondition, LlmNotJudgedAsCondition, ManualWorkflowEvalSource, MatcheRegexCondition, MetricsStaleErrorLastRun, NotContainsCondition, NotEqualsCondition, NotExistsCondition, NumberCompareCondition, ObjectContainsCondition, OutputTarget, Parse, ParseOutput, ParseRequest, ParseWorkflowArtifact, Partition, PartitionChunk, PartitionChunkLikelihood, PartitionConsensus, PartitionRequest, PartitionWorkflowArtifact, PendingBlockExecutionLifecycle, PrimitiveError, PublicHandlePayload, PublishWorkflowRequest, QueryWorkflowTableRequest, QueuedBlockExecutionLifecycle, ReconstructDocumentRef, ReconstructEnrichedRow, ReconstructEnrichedTable, ReconstructEnrichmentOptions, ReconstructRequest, ReconstructResponse, ReconstructSubdocument, RejectReviewRequest, ReplaceWorkflowTableUploadRequest, RetabUsage, Review, ReviewAllOf, ReviewAlways, ReviewAnyOf, ReviewAnyRequiredFieldNull, ReviewAnySplitPagesLt, ReviewBoundaryConfidenceLt, ReviewBranchIn, ReviewCategoryIn, ReviewConfidenceLt, ReviewDecision, ReviewEvaluation, ReviewJsonCondition, ReviewSplitCountNeq, ReviewTopMarginLt, ReviewValidationFailed, ReviewVersion, RunInputs, RunStepWorkflowEvalSource, RunTiming, RunningBlockExecutionLifecycle, SchemaGeneration, Secret, SecretListResponse, SecretResponse, SecretValue, SecretValueResponse, SetSecretRequest, SheetRegion, SimilarityGteCondition, SkippedBlockExecutionLifecycle, SourcesResponse, Split, SplitConsensus, SplitIouCondition, SplitRequest, SplitResult, SplitSubdocumentLikelihood, SplitWorkflowArtifact, StartWithCondition, StepArtifactRef, StoredBlockExecution, Subdocument, SubmitDecisionResponse, Retab::TriggerInfo, UpdateEditTemplateRequest, UpdateExperimentRequest, UpdateWorkflowBlockRequest, UpdateWorkflowEvalRequest, UpdateWorkflowRequest, UpdateWorkflowTableRequest, UploadFileRequest, UsageBlockRecord, UsagePrimitiveDocument, UsagePrimitiveRecord, UsagePrimitiveTriggeredBy, UsageRunRecord, ValidateWorkflowBlockConfigRequest, ValidateWorkflowBlockConfigResponse, ValidationError, VerdictSummary, WhileLoopTermination, Workflow, WorkflowArtifact, WorkflowBlock, WorkflowBlockCreateRequest, WorkflowBlockPosition, WorkflowBlockVersion, WorkflowBlockVersionDiff, WorkflowConfigBlock, WorkflowConfigEdge, WorkflowEdgeCreateRequest, WorkflowEdgeDoc, WorkflowEdgeVersion, WorkflowEdgeVersionDiff, WorkflowEval, WorkflowEvalResult, WorkflowEvalRun, WorkflowEvalRunBlockScope, WorkflowEvalRunSingleScope, WorkflowEvalRunWorkflowScope, WorkflowExperiment, WorkflowExportPayloadRequest, WorkflowExportPayloadResponse, WorkflowGraphVersion, WorkflowGraphVersionDiff, WorkflowPublished, WorkflowRun, WorkflowRunStep, WorkflowTable, WorkflowTableAggregationRequest, WorkflowTableColumn, WorkflowTableDistinctRequest, WorkflowTableExplain, WorkflowTableFilterRule, WorkflowTableListResponse, WorkflowTableProfileColumn, WorkflowTableProfileResponse, WorkflowTableResponse, WorkflowTableRow, WorkflowTableRowsResponse, WorkflowTableSampleRequest, WorkflowTableSchemaResponse, WorkflowTableSearchRequest, WorkflowTableSortRule, WorkflowTableValidationColumnRule, WorkflowTableValidationDiagnostic, WorkflowTableValidationRequest, WorkflowTableValidationResponse, WorkflowVersionFieldDiff
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Attribute Details
#last_response ⇒ Object
Returns the value of attribute last_response.
28
29
30
|
# File 'lib/retab/types/base_model.rb', line 28
def last_response
@last_response
end
|
Class Method Details
.deep_symbolize(value) ⇒ Object
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/retab/types/base_model.rb', line 46
def self.deep_symbolize(value)
case value
when Hash
value.each_with_object({}) { |(k, v), h| h[k.to_sym] = deep_symbolize(v) }
when Array
value.map { |v| deep_symbolize(v) }
else
value
end
end
|
.normalize(json) ⇒ Object
Normalize incoming json into a Hash with symbol keys (all the way
down). The spec-derived initialize body reads hash[:foo] and
passes nested values to other model constructors / discriminator
case ... when "api" then dispatchers. The String branch already
symbolizes deeply via JSON.parse(..., symbolize_names: true); the
Hash branch must match — otherwise list responses (which arrive as
string-keyed Hashes from ListStruct.from_response's JSON.parse)
leave nested data unsymbolized and the discriminator falls through
to the raw else branch instead of constructing the typed variant.
39
40
41
42
43
44
|
# File 'lib/retab/types/base_model.rb', line 39
def self.normalize(json)
return {} if json.nil?
return deep_symbolize(json) if json.is_a?(Hash)
return JSON.parse(json, symbolize_names: true) if json.is_a?(String)
raise ArgumentError, "cannot normalize #{json.class} into a model hash"
end
|
Instance Method Details
#inspect ⇒ Object
72
73
74
75
|
# File 'lib/retab/types/base_model.rb', line 72
def inspect
attrs = to_h.map { |k, v| "#{k}=#{v.inspect}" }.join(" ")
"#<#{self.class.name} #{attrs}>"
end
|
#to_h ⇒ Object
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/retab/types/base_model.rb', line 57
def to_h
hash_attrs = self.class.const_defined?(:HASH_ATTRS) ? self.class.const_get(:HASH_ATTRS) : {}
out = {}
hash_attrs.each do |wire_key, attr|
value = instance_variable_get("@#{attr}")
out[wire_key] = serialize(value)
end
out
end
|
#to_json(*args) ⇒ Object
68
69
70
|
# File 'lib/retab/types/base_model.rb', line 68
def to_json(*args)
to_h.to_json(*args)
end
|