Class: Healthy::Router
- Inherits:
-
Object
- Object
- Healthy::Router
- Defined in:
- lib/healthy/router.rb
Class Attribute Summary collapse
-
.routes ⇒ Object
Returns the value of attribute routes.
Class Method Summary collapse
Class Attribute Details
.routes ⇒ Object
Returns the value of attribute routes.
5 6 7 |
# File 'lib/healthy/router.rb', line 5 def routes @routes end |
Class Method Details
.add(r) ⇒ Object
8 9 10 |
# File 'lib/healthy/router.rb', line 8 def add(r) r.each { |klass, servers| add_route(klass, servers) } end |
.add_route(*route) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/healthy/router.rb', line 12 def add_route(*route) @routes ||= Hash.new{|h, k| h[k] = {}} klass = route.first # this can be nil servers = route[1] @routes[normalized_name(klass)][:klass] = klass @routes[normalized_name(klass)][:servers] = servers end |
.normalized_name(klass) ⇒ Object
21 22 23 24 |
# File 'lib/healthy/router.rb', line 21 def normalized_name(klass) name = klass.respond_to?(:display_name) ? klass.display_name : klass.name name.downcase.gsub(" ", "") end |