Class: Rad::Router::SimpleRouter

Inherits:
Object
  • Object
show all
Defined in:
lib/rad/router/_simple_router.rb

Instance Method Summary collapse

Instance Method Details

#decode(path, params) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rad/router/_simple_router.rb', line 9

def decode path, params
  parts = path[1..-1].split '/'
  if parts.size >= 2
    method = parts.pop.to_sym

    class_path = parts.join('/')
    class_name = class_path.camelize
    klass = class_name.constantize

    return klass, method, params
  end
end

#encode(klass, method, params) ⇒ Object



4
5
6
7
# File 'lib/rad/router/_simple_router.rb', line 4

def encode klass, method, params
  path = "/#{klass.name.underscore}/#{method}"
  return path, params
end