Class: Swee::Routes

Inherits:
Object show all
Defined in:
lib/swee/routes.rb,
lib/template/routes.rb

Defined Under Namespace

Classes: RouteStruct

Constant Summary collapse

@@tables =
{}

Class Method Summary collapse

Class Method Details

._parse(_m, *args) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/swee/routes.rb', line 37

def _parse _m,*args
  _path_info = args[0].to_s
  if args[1] =~ /^(.*)#(.*)$/
    @@tables[_path_info] = RouteStruct.new $1,$2, _m == "match" ? args[2][:via].map(&:to_sym) : [_m.to_sym]
  else
    raise "routes error!"
  end
end

.get(*args) ⇒ Object



21
22
23
# File 'lib/swee/routes.rb', line 21

def get *args
  self._parse "get",*args
end

.match(*args) ⇒ Object



29
30
31
# File 'lib/swee/routes.rb', line 29

def match *args
  self._parse "match",*args
end

.post(*args) ⇒ Object



25
26
27
# File 'lib/swee/routes.rb', line 25

def post *args
  self._parse "post",*args
end

.tablesObject



33
34
35
# File 'lib/swee/routes.rb', line 33

def tables
  @@tables
end