Remove Circular Dependencies by Using Dependency Injection and the Repository Pattern in Ruby - Shopify
Mar 19, 2021

Summary
Introduced the Repository pattern to remove direct circular dependencies between a pricing gem and its consumers (Shopify Core and Storefront Renderer). Defined a contract (PricingRepositoryInterface) in the gem that consumers must implement to provide data. Leveraged Dependency Injection (Constructor Injection) to pass the repository implementation to the gem. Utilized Sorbet interfaces and type signatures to enforce the contract and ensure type safety.