Oxygen
is an private gem which has common Ruby code used across all our apps, gems and engines. It has no framework (Rails) code. Oxygen::Configuration
uses Dry::Configurable
.
You might configure it, in a Rails initalizer, as such:
Oxygen.configure do |c|
c.client_name = 'Acme Inc.'
c.client_key = 'acme'
c.exception_handler = Oxygen::ExceptionHandler.new
c.app_root = Rails.root
c.env = Rails.env
c.logger = Rails.logger
c.fy_month_start = 4
c.fy_month_end = 3
end
In specs we can set any of these configurations to other values so long as we reset it back to know values after each spec has run. It might be better if the initially set values where recorded and then could be restored with Oxygen.configuration.reset!
. Even better might be to allow a block to be passed where some configuration only applies for the duration of the block before it is reverted back to its original state, but I don't know how this might work considering we use a block to do the actual configuration.
Maybe:
configuration = Oxygen::Configuration.new do
c.env = 'production'
end
Oxygen.configure_with(configuration) do
# spec
end
Check out: http://railseventstore.org/docs/subscribe/ for inspiration:
Implementation: https://github.com/RailsEventStore/rails_event_store/blob/a7d5894721fc45357a4d8f9b20097fc27139b05d/ruby_event_store/lib/ruby_event_store/client.rb#L230-L306