Sha256: 3bb3d45a347a37b07ab41b781ebe1cb3f0a628792fad554bed6ba0844c7dc3c4

Contents?: true

Size: 840 Bytes

Versions: 2

Compression:

Stored size: 840 Bytes

Contents

require 'roo_on_rails/config'

module RooOnRails
  module Railties
    class Routemaster < Rails::Railtie
      initializer 'roo_on_rails.routemaster' do
        next unless Config.routemaster_enabled?

        $stderr.puts 'initializer roo_on_rails.routemaster'

        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

      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

2 entries across 2 versions & 1 rubygems

Version Path
roo_on_rails-1.10.0 lib/roo_on_rails/railties/routemaster.rb
roo_on_rails-1.9.0 lib/roo_on_rails/railties/routemaster.rb