Class: Expressr::RouteNode

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

Instance Method Summary collapse

Constructor Details

#initialize(proc, next_node, options = {}) ⇒ RouteNode

Returns a new instance of RouteNode.



3
4
5
6
7
8
# File 'lib/expressr/route_node.rb', line 3

def initialize(proc, next_node, options={})
  @proc = proc
  @next_node = next_node
  @additional_arguments = options[:additional_arguments] || []
  @has_continued = false
end

Instance Method Details

#call(request, response) ⇒ Object



10
11
12
13
14
15
# File 'lib/expressr/route_node.rb', line 10

def call(request, response)
  @request = request
  @response = response
  instance_exec(request, response, &@proc)
  continue unless @has_continued
end

#continueObject



17
18
19
20
# File 'lib/expressr/route_node.rb', line 17

def continue
  @has_continued = true
  @next_node.call(@request, @response, *@additional_arguments)
end