Skip to content

Instantly share code, notes, and snippets.

@dmaze
Created November 26, 2018 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmaze/1cb828a47045b2214a1491fc34cb6144 to your computer and use it in GitHub Desktop.
Save dmaze/1cb828a47045b2214a1491fc34cb6144 to your computer and use it in GitHub Desktop.
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