lib/rasti/web/controller.rb in rasti-web-0.0.4 vs lib/rasti/web/controller.rb in rasti-web-0.0.5
- old
+ new
@@ -13,25 +13,24 @@
@request = request
@response = response
@render = render
end
- def execute(action_name)
- public_send action_name
- rescue => ex
- if respond_to? ex.class.name
- public_send ex.class.name, ex
- else
- raise ex
- end
- end
-
class << self
def action(action_name)
raise "Undefined action '#{action_name}' in #{name}" unless instance_methods.include? action_name.to_sym
Endpoint.new do |req, res, render|
- new(req, res, render).execute(action_name)
+ controller = new req, res, render
+ begin
+ controller.public_send action_name
+ rescue => ex
+ if controller.respond_to? ex.class.name
+ controller.public_send ex.class.name, ex
+ else
+ raise ex
+ end
+ end
end
end
alias_method :>>, :action
\ No newline at end of file