Skip to content

Instantly share code, notes, and snippets.

@dmaze
Created Apr 18, 2018
Embed
What would you like to do?
A dry-system application that uses an environment variable
# frozen_string_literal: true
require 'dry/system/container'
require 'dry/system/components'
require 'dry/types'
module Types
include Dry::Types.module
end
class Application < Dry::System::Container
use(:env)
boot(:settings, from: :system) do
settings do
key :an_int, Types::Coercible::Int.default(17)
end
end
end
Import = Application.injector
class Main
include Import['settings']
def call
puts "The magic number is #{settings.an_int}"
end
end
Main.new.()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment