Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ShopifyEng/11c5e3a0f4b8ce3c7da5c701c9ddcf18 to your computer and use it in GitHub Desktop.
Save ShopifyEng/11c5e3a0f4b8ce3c7da5c701c9ddcf18 to your computer and use it in GitHub Desktop.
module PricingEngine
class Engine
# @param repository [PricingEngine::PricingRepositoryInterface] environment specific functions to
# access db and cache data.
#
# @return [void]
def initialize(repository)
@repository = repository
end
#...
# Calculates the price for variants given the buyer context.
#
# @param context [Schema::BuyerContext] the buyer context.
#
# @return [Array<PricingEngine::Schema::Price>] An array of prices for the context passed.
def calculate_prices_for_variants(context)
variant_ids = get_variant_ids_from_context(context)
variants = @repository.variants_by_ids(variant_ids)
process(variants)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment