module Mojito::Controllers::Method
Public Class Methods
args_for(arity, path_info)
click to toggle source
# File lib/mojito/controllers/method.rb, line 30 def self.args_for(arity, path_info) if arity >= 0 args = path_info.split('/', arity + 1) if args.length == arity [args, ''] elsif args.length == arity + 1 [args, args.pop] else [nil, path_info] end else args = path_info.split('/') if args.length >= arity.abs - 1 [args, ''] else [nil, path_info] end end end
Public Instance Methods
__dispatch()
click to toggle source
# File lib/mojito/controllers/method.rb, line 8 def __dispatch if m = %r{^/?(?<meth>\w+)(?:/|$)}.match(request.path_info) meth = m['meth'].to_sym if respond_to?(meth.to_sym) env['SCRIPT_NAME'] += m.to_s arity = method(meth).arity args, env['PATH_INFO'] = Method.args_for(arity, m.post_match) args.collect! {|a| CGI.unescape a } if args if args send meth, *args ok! else Mojito::R::StatusCodes.instance_method(:not_found!).bind(self).call end else Mojito::R::StatusCodes.instance_method(:not_found!).bind(self).call end else Mojito::R::StatusCodes.instance_method(:not_found!).bind(self).call end end