Sha256: 7bd20cf89f34583d8a0a728a1808a1fea7c31b955ca47a99807ffd80ac649095

Contents?: true

Size: 854 Bytes

Versions: 11

Compression:

Stored size: 854 Bytes

Contents

# frozen_string_literal: true

module BBK
  module App
    class Dispatcher
      class Route

        attr_reader :uri, :scheme, :domain, :routing_key

        # Example: mq://gw@service.smev.request
        def initialize(string)
          @uri = URI(string)
          @scheme = uri.scheme
          @domain = uri.user
          @routing_key = "#{uri.host}#{uri.path}"

          # raise 'domain must present in route' if @domain.blank?
          raise 'routing_key must present in route' if @routing_key.blank?
        end

        def to_s
          @uri.to_s
        end

        def ==(other)
          if other.is_a?(String)
            to_s == other
          else
            super
          end
        end

        def params
          @params ||= Hash[URI.decode_www_form(uri.query.presence || '')] 
        end

      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
bbk-app-1.1.1.273627 lib/bbk/app/dispatcher/route.rb
bbk-app-1.1.1.273338 lib/bbk/app/dispatcher/route.rb
bbk-app-1.1.1.273312 lib/bbk/app/dispatcher/route.rb
bbk-app-1.1.1.273294 lib/bbk/app/dispatcher/route.rb
bbk-app-1.1.0.219406 lib/bbk/app/dispatcher/route.rb
bbk-app-1.1.0.216998 lib/bbk/app/dispatcher/route.rb
bbk-app-1.1.0.204569 lib/bbk/app/dispatcher/route.rb
bbk-app-1.1.0.200751 lib/bbk/app/dispatcher/route.rb
bbk-app-1.1.0.200186 lib/bbk/app/dispatcher/route.rb
bbk-app-1.1.0.199675 lib/bbk/app/dispatcher/route.rb
bbk-app-1.1.0.199604 lib/bbk/app/dispatcher/route.rb