Skip to content

Instantly share code, notes, and snippets.

@filp
Created April 16, 2013 11:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save filp/5395267 to your computer and use it in GitHub Desktop.
Save filp/5395267 to your computer and use it in GitHub Desktop.
class Route {
def self.reader(v) {
define_method(v, \{ get_instance_variable(v) });
}
reader('verb);
reader('path);
reader('callable);
def init(verb, path, callable) {
[@verb, @path, @callable] = [verb, path, callable];
# stores filters for path arguments.
# @example:
# r.get("/:id", x).where('foo, %r{\d{,3}});
@argument_filters = {};
}
def where(argument, filter) {
if(!@argument_filters.has_key(argument)) {
@argument_filters[argument] = [];
}
@argument_filters[argument].push(filter);
self;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment