Skip to content

Instantly share code, notes, and snippets.

@streppa
Created December 13, 2017 06:52
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 streppa/3643f16d7e0401a6e35d45e6616af11d to your computer and use it in GitHub Desktop.
Save streppa/3643f16d7e0401a6e35d45e6616af11d to your computer and use it in GitHub Desktop.
Issue with old berg example of namespacing a bootable component
# /app/system/boot/journey.rb
Application.namespace :space do |space|
space.finalize(:journey) do
init do
spaceship = Dry::Container.new
spaceship.register :about, "A single thruster leisure vessel."
space.register(:ship, spaceship)
end
start do
ship = container["space.ship"]
space.register(:journey, Dry::Struct.new(ship: ship, pilot: 'Captain Clarence Oveur'))
end
end
end
Uncaught exception: Nothing registered with the key "space.ship"
/home/streppa/dry-rb/dry-container/lib/dry/container/resolver.rb:22:in `block in call'
/home/streppa/dry-rb/dry-container/lib/dry/container/resolver.rb:21:in `fetch'
/home/streppa/dry-rb/dry-container/lib/dry/container/resolver.rb:21:in `call'
/home/streppa/dry-rb/dry-container/lib/dry/container/mixin.rb:112:in `resolve'
/home/streppa/dry-rb/dry-container/lib/dry/container/mixin.rb:125:in `[]'
/home/streppa/blah/system/boot/journey.rb:10:in `block (3 levels) in <top (required)>'
/home/streppa/dry-rb/dry-system/lib/dry/system/lifecycle.rb:119:in `trigger!'
/home/streppa/dry-rb/dry-system/lib/dry/system/lifecycle.rb:84:in `start'
/home/streppa/dry-rb/dry-system/lib/dry/system/lifecycle.rb:56:in `block in call'
/home/streppa/dry-rb/dry-system/lib/dry/system/lifecycle.rb:54:in `each'
/home/streppa/dry-rb/dry-system/lib/dry/system/lifecycle.rb:54:in `call'
/home/streppa/dry-rb/dry-system/lib/dry/system/components/bootable.rb:96:in `start'
/home/streppa/dry-rb/dry-system/lib/dry/system/booter.rb:77:in `block (2 levels) in start'
/home/streppa/dry-rb/dry-system/lib/dry/system/booter.rb:64:in `block (2 levels) in init'
/home/streppa/dry-rb/dry-system/lib/dry/system/booter.rb:93:in `block in call'
/home/streppa/dry-rb/dry-system/lib/dry/system/booter.rb:117:in `with_component'
/home/streppa/dry-rb/dry-system/lib/dry/system/booter.rb:88:in `call'
/home/streppa/dry-rb/dry-system/lib/dry/system/booter.rb:62:in `block in init'
/home/streppa/dry-rb/dry-system/lib/dry/system/booter.rb:117:in `with_component'
/home/streppa/dry-rb/dry-system/lib/dry/system/booter.rb:61:in `init'
/home/streppa/dry-rb/dry-system/lib/dry/system/booter.rb:76:in `block in start'
/home/streppa/dry-rb/dry-system/lib/dry/system/booter.rb:117:in `with_component'
/home/streppa/dry-rb/dry-system/lib/dry/system/booter.rb:73:in `start'
/home/streppa/dry-rb/dry-system/lib/dry/system/booter.rb:53:in `block in finalize!'
/home/streppa/dry-rb/dry-system/lib/dry/system/booter/component_registry.rb:14:in `each'
/home/streppa/dry-rb/dry-system/lib/dry/system/booter/component_registry.rb:14:in `each'
/home/streppa/dry-rb/dry-system/lib/dry/system/booter.rb:52:in `finalize!'
/home/streppa/dry-rb/dry-system/lib/dry/system/container.rb:295:in `finalize!'
/home/streppa/blah/simple.rb:9:in `<top (required)>'
# /app/simple.rb
require 'dry/system/container'
Application Dry::System::Container
configure do |config|
config.name = :app
end
end
Application.finalize!
Application[:journey]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment