lib/seymour/renderable.rb in seymour-0.0.8 vs lib/seymour/renderable.rb in seymour-0.0.9

- old
+ new

@@ -4,33 +4,28 @@ end module Renderable extend ActiveSupport::Concern - module InstanceMethods + def render_html + render("seymour/render", "activity", "seymour.activity" => self) + rescue RenderError + return nil + end - def render_html - render("seymour/render", "activity", "seymour.activity" => self) - rescue RenderError - return nil - end + def render(controller_name, action_name, env = {}) + # TODO define proper server name + # { "REQUEST_URI" => "", "SERVER_NAME" => 'http://www.example.com' }.merge(env)) - def render(controller_name, action_name, env = {}) - # TODO define proper server name - # { "REQUEST_URI" => "", "SERVER_NAME" => 'http://www.example.com' }.merge(env)) + env = Rack::MockRequest.env_for("/", + { "REQUEST_URI" => "", "SERVER_NAME" => '' }.merge(env)) - env = Rack::MockRequest.env_for("/", - { "REQUEST_URI" => "", "SERVER_NAME" => '' }.merge(env)) + controller_class = "#{controller_name}_controller".classify.constantize - controller_class = "#{controller_name}_controller".classify.constantize - - status, headers, response = controller_class.action(action_name.to_sym).call(env) - raise RenderError.new("#{controller_name}##{action_name}") unless status.to_i == 200 - response.body - end - + status, headers, response = controller_class.action(action_name.to_sym).call(env) + raise RenderError.new("#{controller_name}##{action_name}") unless status.to_i == 200 + response.body end - end end \ No newline at end of file