Instantly share code, notes, and snippets.

@dmaze /app.rb
Created Nov 26, 2018

Embed
What would you like to do?
dry-system doesn't memoize auto-registered components
# frozen_string_literal: true
require 'dry/system/container'
class Application < Dry::System::Container
configure do |config|
config.auto_register = ['lib']
end
load_paths!('lib')
end
Application.finalize!
Application[:component].h[:k] = :v
v = Application[:component].h[:k]
print v ? v : "[nil]"
# frozen_string_literal: true
#
# This file goes in lib/component.rb
class Component
attr_accessor :h
def initialize
@h = {}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment