module Contexts class Base def key end def required? true end def current end def default end def constraints end def url_option current end def apply(controller, value) end def matches_constraints?(request) if (con = constraints).nil? true elsif con.respond_to?(:matches?) con.matches?(request) elsif con.is_a?(Proc) con.call(request) else con === request.params[key] end end end end