Created
November 26, 2018 16:22
-
-
Save dmaze/1cb828a47045b2214a1491fc34cb6144 to your computer and use it in GitHub Desktop.
dry-system doesn't memoize auto-registered components
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
# 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]" |
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
# 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