// Generated by CoffeeScript 1.7.1
(function() {
  var Route, handlers;

  handlers = require('./handlers');

  Route = (function() {
    function Route(path, method, handler, detail, _before, _after) {
      this.path = path;
      this.method = method;
      this.handler = handler;
      this.detail = detail != null ? detail : false;
      this._before = _before != null ? _before : [];
      this._after = _after != null ? _after : [];
    }

    Route.prototype.before = function(before) {
      return this._before.push(before);
    };

    Route.prototype.after = function(after) {
      return this._after.push(after);
    };

    Route.prototype.url = function() {
      var url;
      if (this.detail) {
        return url = "/:id([0-9a-fA-F]{0,24})" + this.path;
      } else {
        return url = "" + this.path;
      }
    };

    Route.prototype.handlers = function() {
      return this._before.concat(this.handler.handle, this._after);
    };

    Route.prototype.toString = function() {
      return "('" + this.path + "', " + this.method + ", detail=" + this.detail + ")";
    };

    Route.makeRoute = function(path, method, handler, detail) {
      if ((path != null ? path.length : void 0) > 0 && path.charAt(0) !== '/') {
        path = "/" + path;
      }
      return new Route(path, method, handler, detail);
    };

    return Route;

  })();

  module.exports = Route;

}).call(this);
