Sha256: a11ec08dd59b033c44a1d8914c71711c723383b37556ffc283ce9e987757cd7d

Contents?: true

Size: 910 Bytes

Versions: 3

Compression:

Stored size: 910 Bytes

Contents

require 'roo_on_rails/config'

module RooOnRails
  module Railties
    class Routemaster < Rails::Railtie
      initializer 'roo_on_rails.routemaster' do
        Rails.logger.with initializer: 'roo_on_rails.routemaster' do |log|
          next unless Config.routemaster_enabled?
          log.debug 'loading'

          abort 'Aborting: ROUTEMASTER_URL and ROUTEMASTER_UUID are required' if bus_details_missing?

          require 'routemaster/client'

          ::Routemaster::Client.configure do |config|
            config.url = routemaster_url
            config.uuid = routemaster_uuid
          end
        end
      end

      private

      def bus_details_missing?
        routemaster_url.blank? || routemaster_uuid.blank?
      end

      def routemaster_url
        ENV.fetch('ROUTEMASTER_URL')
      end

      def routemaster_uuid
        ENV.fetch('ROUTEMASTER_UUID')
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
roo_on_rails-1.12.0 lib/roo_on_rails/railties/routemaster.rb
roo_on_rails-1.11.1 lib/roo_on_rails/railties/routemaster.rb
roo_on_rails-1.11.0 lib/roo_on_rails/railties/routemaster.rb