Change summary
lib/customer_repo.rb | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
Detailed changes
@@ -1,6 +1,7 @@
# frozen_string_literal: true
require "lazy_object"
+require "value_semantics/monkey_patched"
require_relative "customer"
require_relative "polyfill"
@@ -8,16 +9,11 @@ require_relative "polyfill"
class CustomerRepo
class NotFound < RuntimeError; end
- def initialize(
- redis: LazyObject.new { REDIS },
- db: LazyObject.new { DB },
- braintree: LazyObject.new { BRAINTREE },
- sgx_repo: TrivialBackendSgxRepo.new
- )
- @redis = redis
- @db = db
- @braintree = braintree
- @sgx_repo = sgx_repo
+ value_semantics do
+ redis Anything(), default: LazyObject.new { REDIS }
+ db Anything(), default: LazyObject.new { DB }
+ braintree Anything(), default: LazyObject.new { BRAINTREE }
+ sgx_repo Anything(), default: TrivialBackendSgxRepo.new
end
def find(customer_id)