Class: BBK::App::Dispatcher::Route
- Inherits:
-
Object
- Object
- BBK::App::Dispatcher::Route
- Defined in:
- lib/bbk/app/dispatcher/route.rb
Instance Attribute Summary collapse
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#routing_key ⇒ Object
readonly
Returns the value of attribute routing_key.
-
#scheme ⇒ Object
readonly
Returns the value of attribute scheme.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(string) ⇒ Route
constructor
Example: mq://gw@service.smev.request.
- #params ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(string) ⇒ Route
Example: mq://gw@service.smev.request
11 12 13 14 15 16 17 18 19 |
# File 'lib/bbk/app/dispatcher/route.rb', line 11 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 |
Instance Attribute Details
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
8 9 10 |
# File 'lib/bbk/app/dispatcher/route.rb', line 8 def domain @domain end |
#routing_key ⇒ Object (readonly)
Returns the value of attribute routing_key.
8 9 10 |
# File 'lib/bbk/app/dispatcher/route.rb', line 8 def routing_key @routing_key end |
#scheme ⇒ Object (readonly)
Returns the value of attribute scheme.
8 9 10 |
# File 'lib/bbk/app/dispatcher/route.rb', line 8 def scheme @scheme end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
8 9 10 |
# File 'lib/bbk/app/dispatcher/route.rb', line 8 def uri @uri end |
Instance Method Details
#==(other) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/bbk/app/dispatcher/route.rb', line 25 def ==(other) if other.is_a?(String) to_s == other else super end end |
#params ⇒ Object
33 34 35 |
# File 'lib/bbk/app/dispatcher/route.rb', line 33 def params @params ||= Hash[URI.decode_www_form(uri.query.presence || '')] end |
#to_s ⇒ Object
21 22 23 |
# File 'lib/bbk/app/dispatcher/route.rb', line 21 def to_s @uri.to_s end |