Module: SpreeCmCommissioner::Integrations::IntegrationMappable
- Extended by:
- ActiveSupport::Concern
- Included in:
- Guest
- Defined in:
- app/models/concerns/spree_cm_commissioner/integrations/integration_mappable.rb
Overview
IntegrationMappable provides a polymorphic mapping layer between internal records and external integration IDs.
Design Rationale: Why use a separate mapping table instead of adding external_id columns directly?
-
No Schema Changes Required: Adding a new integration doesn't require migrations to add columns to every table. The mapping table is reusable across all models that include this concern.
-
Polymorphic Scalability: A single mapping table handles multiple record types (Spree::Product, Spree::Taxon, SeatLayout, etc.) without duplicating external_id columns across the schema.
-
Multiple Source Support: Records can have mappings to multiple integrations simultaneously. A single product might be synced from StadiumXV1, LarrytaV1, and other sources. Direct columns would require one per integration.
-
Acceptable Performance Trade-off: While joins are slightly slower than direct column lookups, the performance impact is negligible in practice because:
- Lookups occur primarily during background jobs (async, not blocking user requests)
- Integration sync operations (incremental, full, webhook)
- Occasional user-triggered operations (not on every page load) The flexibility and maintainability gains far outweigh the minimal performance cost.