This file contains 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
class B < Minitest::Test | |
test "test 1" do | |
#.... # runs twice | |
end | |
class A < B | |
test "test 2" do | |
#.... | |
end | |
end |
This file contains 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
module Middleware | |
class BasicMiddleware | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
# Before the app is called. | |
status, headers, response = @app.call(env) | |
# After the app is called. |
This file contains 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
module Middleware | |
class MeasureLogs | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
start_time = Time.now | |
status, headers, response = @app.call(env) | |
end_time = Time.now |
This file contains 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
require 'securerandom' | |
module Middleware | |
class LogRequestId | |
REQUEST_ID = "X-Request-Id" | |
def initialize(app) | |
@app = app | |
end |
This file contains 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
# ----------------------------- Gem ----------------------------- | |
module PricingEngine | |
module PricingRepositoryInterface | |
extend T::Sig | |
extend T::Helpers | |
interface! | |
sig { abstract.params(ids: T::Array[Integer]).returns(T::Array[Schema::Variant]) } | |
def variants_by_ids(ids);end |
This file contains 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
# ----------------------------- Gem ----------------------------- | |
module PricingEngine | |
class PricingRepositoryInterface | |
def variants_by_ids(ids) | |
raise NotImplemented | |
end | |
def variants_by_titles(titles) | |
raise NotImplemented | |
end |
This file contains 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
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 |
This file contains 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 2 Logic | |
require 'pricing_engine' | |
module StorefrontRenderer | |
class PricingRepository < PricingEngine::PricingRepositoryInterface | |
def variants_by_ids(ids) | |
variants = DataStoreConnection.execute("SELECT title, price FROM variants WHERE id in (?)", ids).limit(50) | |
variants.map { |variant| PricingEngine::Schema::Variant.new(title: variant.title, price: variant.price) } |
This file contains 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 |
This file contains 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
module PricingEngine | |
class PricingRepositoryInterface | |
def variants_by_ids(ids) | |
raise NotImplemented | |
end | |
def variants_by_titles(titles) | |
raise NotImplemented | |
end | |
end |
NewerOlder