Class: RackStep::Route

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

Overview

Represents a single route. The verb can be ‘GET’, ‘PUT’, ‘POST’ or ‘DELETE’. The path is a string with something like ‘users’, the controller is the name of the class that will process this type of request and the method parameter is the name of the method that will be executed.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(verb, path, controller, method) ⇒ Route

Returns a new instance of Route.



50
51
52
53
54
55
# File 'lib/router.rb', line 50

def initialize(verb, path, controller, method)
  @verb = verb
  @path = path
  @controller = controller
  @method = method
end

Instance Attribute Details

#controllerObject

Returns the value of attribute controller.



48
49
50
# File 'lib/router.rb', line 48

def controller
  @controller
end

#methodObject

Returns the value of attribute method.



48
49
50
# File 'lib/router.rb', line 48

def method
  @method
end

#pathObject

Returns the value of attribute path.



48
49
50
# File 'lib/router.rb', line 48

def path
  @path
end

#verbObject

Returns the value of attribute verb.



48
49
50
# File 'lib/router.rb', line 48

def verb
  @verb
end

Instance Method Details

#idObject

Unique id of the route (verb + path). Eg: ‘GETuser’.



58
59
60
# File 'lib/router.rb', line 58

def id
  verb + path
end