def add(self, template, resource, name=None):
        """Add a route to a resource.

        The optional `name` assigns a name to this route that can be used when
        building URLs. The name must be unique within this Mapper object.
        """
        # Special case for standalone handler functions
        if hasattr(resource, '_rhino_meta'):
            route = Route(
                    template, Resource(resource), name=name, ranges=self.ranges)
        else:
            route = Route(
                    template, resource, name=name, ranges=self.ranges)
        obj_id = id(resource)
        if obj_id not in self._lookup:
            # It's ok to have multiple routes for the same object id, the
            # lookup will return the first one.
            self._lookup[obj_id] = route
        if name is not None:
            if name in self.named_routes:
                raise InvalidArgumentError("A route named '%s' already exists in this %s object."
                        % (name, self.__class__.__name__))
            self.named_routes[name] = route
        self.routes.append(route)
Add a route to a resource.

        The optional `name` assigns a name to this route that can be used when
        building URLs. The name must be unique within this Mapper object.