Class: Twke::Routes::RoutePrefix

Inherits:
Object
  • Object
show all
Defined in:
lib/twke/routes.rb

Instance Method Summary collapse

Constructor Details

#initialize(str = nil) ⇒ RoutePrefix

Returns a new instance of RoutePrefix.



4
5
6
7
# File 'lib/twke/routes.rb', line 4

def initialize(str = nil)
  @levels = []
  @levels.push(str) if str
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, &blk) ⇒ Object



15
16
17
18
19
# File 'lib/twke/routes.rb', line 15

def method_missing(name, &blk)
  @levels.push(name)
  yield
  @levels.pop
end

Instance Method Details

#route(str, *opts, &blk) ⇒ Object



9
10
11
12
13
# File 'lib/twke/routes.rb', line 9

def route(str, *opts, &blk)
  @levels.push(str)
  Routes.add(@levels.join(" "), *opts, &blk)
  @levels.pop
end