module Kaffe::Actions
Public Class Methods
included(base)
click to toggle source
# File lib/kaffe/actions.rb, line 69 def self.included(base) base.extend(ClassMethods) end
Public Instance Methods
action!()
click to toggle source
# File lib/kaffe/actions.rb, line 57 def action! begin dispatch_action! rescue NoMethodError => e register_error(404, "Could Not Find Action: #{e.message}\n#{e.backtrace.join("\n")}") rescue Exception => error register_error(500, error.message) ensure # TODO: after filter! end end
dispatch_action!()
click to toggle source
# File lib/kaffe/actions.rb, line 34 def dispatch_action! routes = self.class.actions[@request.request_method] path = @request.path_info routes.each do |expr, keys, id| if path.match(expr) values = $~.captures.to_a if keys == "splat" hash = {'splat' => values } else hash = Hash[keys.zip(values)] end @request.params.merge! hash m = method(id) throw :success, if m.arity != 0 m.call(*values) else m.call end end end raise NoMethodError.new("Could not find matching action for #{path}") end