lib/merb/merb_controller.rb in merb-0.3.1 vs lib/merb/merb_controller.rb in merb-0.3.3

- old
+ new

@@ -19,12 +19,12 @@ :_template_root, :_layout_root self._layout = :application self._session_id_key = :_session_id self._template_extensions = { } - self._template_root = File.expand_path(MERB_ROOT / "dist/app/views") - self._layout_root = File.expand_path(MERB_ROOT / "dist/app/views/layout") + self._template_root = File.expand_path(MERB_VIEW_ROOT) + self._layout_root = File.expand_path(MERB_VIEW_ROOT / "layout") include Merb::ControllerMixin include Merb::RenderMixin include Merb::ResponderMixin @@ -49,10 +49,12 @@ if [Mongrel::Const::APPLICATION_JSON, Mongrel::Const::TEXT_JSON].include?(@env[Mongrel::Const::UPCASE_CONTENT_TYPE]) MERB_LOGGER.info("JSON Request") json = JSON.parse(request.read || "") || {} json = MerbHash.new(json) if json.is_a? Hash querystring.update(json) + elsif [Mongrel::Const::APPLICATION_XML, Mongrel::Const::TEXT_XML].include?(@env[Mongrel::Const::UPCASE_CONTENT_TYPE]) + querystring.update(Hash.from_xml(request.read).with_indifferent_access) else querystring.update(query_parse(request.read)) end end @@ -62,11 +64,11 @@ allow = [:post, :put, :delete] allow << :get if MERB_ENV == 'development' if @params.key?(:_method) && allow.include?(@method) @method = @params.delete(:_method).downcase.intern end - @request = Request.new(@env, @method) + @request = Request.new(@env, @method, request) MERB_LOGGER.info("Params: #{params.inspect}\nCookies: #{cookies.inspect}") end def dispatch(action=:to_s) @@ -176,15 +178,17 @@ ok = true end else ok = true end - case filter - when Symbol, String - send(filter) if ok - when Proc - filter.call(self) if ok - end + if ok + case filter + when Symbol, String + send(filter) + when Proc + filter.call(self) + end + end end return :filter_chain_completed end # #before is a class method that allows you to specify before