Class: Routing::Middleware Abstract

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

Overview

This class is abstract.

An abstract middleware class to illustrate how you can build your own.

Instance Method Summary collapse

Instance Method Details

#calculate(geo_points) {|Array<GeoPoint>| ... } ⇒ Array<GeoPoint>

The only method your own middleware has to implement to work.

Parameters:

  • geo_points (Array<GeoPoint>)

    The array of GeoPoints that should be routed.

Yields:

  • (Array<GeoPoint>)

    Passes the geo_points on to the next middleware in the stack. Please note, that you always have to call yield in order to make the middleware stack proceed.

    If you will return a value before yielding, you will cancel the rest of the middleware stack.

Returns:



21
22
23
24
25
# File 'lib/routing/middleware.rb', line 21

def calculate(geo_points)
  # manipulate geo points before routing here
  yield(geo_points) # hand control to the next middleware in the stack
  # manipulate geo points after routing here
end