Class: Legion::Extensions::Llm::Inventory::MutationResult
- Inherits:
-
Data
- Object
- Data
- Legion::Extensions::Llm::Inventory::MutationResult
- Defined in:
- lib/legion/extensions/llm/inventory/records.rb
Overview
The outcome of a registry mutation. Expected stale results use applied: false; every other reason requires applied: true. See 10.8.
Instance Attribute Summary collapse
-
#applied ⇒ Object
readonly
Returns the value of attribute applied.
-
#generation ⇒ Object
readonly
Returns the value of attribute generation.
-
#instance_key ⇒ Object
readonly
Returns the value of attribute instance_key.
-
#instance_record ⇒ Object
readonly
Returns the value of attribute instance_record.
-
#publication_status ⇒ Object
readonly
Returns the value of attribute publication_status.
-
#reason ⇒ Object
readonly
Returns the value of attribute reason.
Instance Method Summary collapse
- #applied? ⇒ Boolean
-
#initialize(**kwargs) ⇒ MutationResult
constructor
A new instance of MutationResult.
- #validate_applied_reason!(applied, reason) ⇒ Object
Constructor Details
#initialize(**kwargs) ⇒ MutationResult
Returns a new instance of MutationResult.
549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 |
# File 'lib/legion/extensions/llm/inventory/records.rb', line 549 def initialize(**kwargs) kwargs = { publication_status: nil, instance_record: nil }.merge(kwargs) RecordSupport.check_unknown_kwargs!(kwargs: kwargs, members: self.class.members) applied = kwargs[:applied] reason = kwargs[:reason] instance_key = kwargs[:instance_key] publication_status = kwargs[:publication_status] instance_record = kwargs[:instance_record] RecordSupport.boolean!(value: applied, field: :applied) raise Errors::ValidationError, 'reason must be a Taxonomies::MUTATION_REASONS value' unless Taxonomies::MUTATION_REASONS.include?(reason) validate_applied_reason!(applied, reason) raise Errors::ValidationError, 'instance_key must be an InstanceKey' unless instance_key.is_a?(Identity::InstanceKey) raise Errors::ValidationError, 'publication_status must be a PublicationStatus or nil' unless publication_status.nil? || publication_status.is_a?(PublicationStatus) raise Errors::ValidationError, 'instance_record must be an InstanceRecord or nil' unless instance_record.nil? || instance_record.is_a?(InstanceRecord) super( applied: applied, reason: reason, generation: RecordSupport.nonnegative_integer(value: kwargs[:generation], field: :generation), instance_key: instance_key, publication_status: publication_status, instance_record: instance_record ) end |
Instance Attribute Details
#applied ⇒ Object (readonly)
Returns the value of attribute applied
546 547 548 |
# File 'lib/legion/extensions/llm/inventory/records.rb', line 546 def applied @applied end |
#generation ⇒ Object (readonly)
Returns the value of attribute generation
546 547 548 |
# File 'lib/legion/extensions/llm/inventory/records.rb', line 546 def generation @generation end |
#instance_key ⇒ Object (readonly)
Returns the value of attribute instance_key
546 547 548 |
# File 'lib/legion/extensions/llm/inventory/records.rb', line 546 def instance_key @instance_key end |
#instance_record ⇒ Object (readonly)
Returns the value of attribute instance_record
546 547 548 |
# File 'lib/legion/extensions/llm/inventory/records.rb', line 546 def instance_record @instance_record end |
#publication_status ⇒ Object (readonly)
Returns the value of attribute publication_status
546 547 548 |
# File 'lib/legion/extensions/llm/inventory/records.rb', line 546 def publication_status @publication_status end |
#reason ⇒ Object (readonly)
Returns the value of attribute reason
546 547 548 |
# File 'lib/legion/extensions/llm/inventory/records.rb', line 546 def reason @reason end |
Instance Method Details
#applied? ⇒ Boolean
576 577 578 |
# File 'lib/legion/extensions/llm/inventory/records.rb', line 576 def applied? applied end |
#validate_applied_reason!(applied, reason) ⇒ Object
580 581 582 583 584 585 586 587 |
# File 'lib/legion/extensions/llm/inventory/records.rb', line 580 def validate_applied_reason!(applied, reason) non_applied = %i[stale_publisher stale_probe already_removed] if applied raise Errors::ValidationError, "applied result cannot use reason #{reason}" if non_applied.include?(reason) elsif !non_applied.include?(reason) raise Errors::ValidationError, "non-applied result requires a stale/already-removed reason, got #{reason}" end end |