Created
March 18, 2021 12:46
-
-
Save ShopifyEng/c75b8879ae8326643a7a83ef70032095 to your computer and use it in GitHub Desktop.
Repository Pattern
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Consumer 1 Logic | |
require 'pricing_engine' | |
module ShopifyCore | |
class PricingRepository < PricingEngine::PricingRepositoryInterface | |
def variants_by_ids(ids) | |
variants = ProductVariant.where(id: ids).select(:title, :price).limit(50) | |
variants.map { |variant| PricingEngine::Schema::Variant.new(title: variant.title, price: variant.price) } | |
end | |
def variants_by_titles(titles) | |
variants = ProductVariant.where(title: titles).select(:title, :price).limit(50) | |
variants.map { |variant| PricingEngine::Schema::Variant.new(title: variant.title, price: variant.price) } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment