Class: Publication::Reviser
- Inherits:
-
BaseService
- Object
- BaseService
- Publication::Reviser
- Defined in:
- app/services/publication/reviser.rb
Overview
Creates the next revision of a publication: deep-dups the record, bumps the
SKU revision letter, discontinues the original — and links the two through
the REAL relationship machinery:
- +items.successor_item_id+ — the item-level succession chain (the same
column product succession uses); readers walk this chain instead of the
fragile "sku ILIKE '%'" pattern match, which false-matches
across SKU prefixes (TZ-100 canonical also matched TZ-1000-A) - RelatedPublication.link_revision — the typed publication link with
provenance metadata
Service object: reviser.
Defined Under Namespace
Classes: Result
Instance Attribute Summary
Attributes inherited from BaseService
Instance Method Summary collapse
Methods inherited from BaseService
#initialize, #log_debug, #log_error, #log_info, #log_warning, #logger, #tagged_logger
Constructor Details
This class inherits a constructor from BaseService
Instance Method Details
#process(original_publication) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/services/publication/reviser.rb', line 22 def process(original_publication) new_publication = original_publication.deep_dup new_publication.sku = original_publication.new_revision_sku # deep_dup copies successor_item_id — the new revision is the chain END, # it must not inherit the original's successor pointer. new_publication.successor_item = nil if new_publication.save original_publication.update!(successor_item: new_publication) link_revision(original_publication, new_publication) original_publication.discontinue_self_and_dependents Result.new(success: true, new_publication: new_publication) else Result.new(success: false, errors: new_publication.errors.) end end |