Module: Kaffe::Actions
- Included in:
- Base
- Defined in:
- lib/kaffe/actions.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
69 70 71 |
# File 'lib/kaffe/actions.rb', line 69 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#action! ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/kaffe/actions.rb', line 57 def action! begin dispatch_action! rescue NoMethodError => e register_error(404, "Could Not Find Action: #{e.}\n#{e.backtrace.join("\n")}") rescue Exception => error register_error(500, error.) ensure # TODO: after filter! end end |
#dispatch_action! ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# 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 |