Class: Funnel::Routing::Routes
- Inherits:
-
Object
- Object
- Funnel::Routing::Routes
- Defined in:
- lib/funnel/routing/routes.rb
Constant Summary collapse
- @@instance =
nil
Class Method Summary collapse
Instance Method Summary collapse
- #connect(path, opts) ⇒ Object
- #default(opts) ⇒ Object
- #get_default ⇒ Object
- #get_handler(path) ⇒ Object
-
#initialize ⇒ Routes
constructor
A new instance of Routes.
Constructor Details
#initialize ⇒ Routes
Returns a new instance of Routes.
18 19 20 |
# File 'lib/funnel/routing/routes.rb', line 18 def initialize @routes = {} end |
Class Method Details
.draw {|@@instance| ... } ⇒ Object
12 13 14 15 |
# File 'lib/funnel/routing/routes.rb', line 12 def self.draw @@instance = Routes.new unless @@instance yield @@instance end |
.get_handler(path) ⇒ Object
8 9 10 |
# File 'lib/funnel/routing/routes.rb', line 8 def self.get_handler path @@instance.get_handler(path) end |
Instance Method Details
#connect(path, opts) ⇒ Object
22 23 24 |
# File 'lib/funnel/routing/routes.rb', line 22 def connect path, opts @routes[path] = Route.new(path, opts) end |
#default(opts) ⇒ Object
26 27 28 |
# File 'lib/funnel/routing/routes.rb', line 26 def default opts @routes[:default] = Route.new(:default, opts) end |
#get_default ⇒ Object
30 31 32 |
# File 'lib/funnel/routing/routes.rb', line 30 def get_default @routes.key?(:default) ? @routes[:default].handler : Funnel::Servers::DummyServer end |
#get_handler(path) ⇒ Object
34 35 36 |
# File 'lib/funnel/routing/routes.rb', line 34 def get_handler path @routes.key?(path) ? @routes[path].handler : @routes[:default].handler end |