Sha256: 5f9d31e1b52c3110e5d2bdf9804f372bd45d07333a1f762387c5b0fbcd99045b
Contents?: true
Size: 1.7 KB
Versions: 1
Compression:
Stored size: 1.7 KB
Contents
module Rtml::Controller::RenderHelpers def render_with_rtml_option(options = nil, extra_options = {}, &block) if (rtml_options = options).is_a?(Hash) || (rtml_options = extra_options).is_a?(Hash) rtml_options = extra_options if !rtml_options.key?(:rtml) && extra_options.is_a?(Hash) if rtml_action = rtml_options.delete(:rtml) return attempt_rtml_action(rtml_action) end end render_without_rtml_option(options, extra_options, &block) end def attempt_rtml_action(rtml_action, options = {}) if rtml_helpers.respond_to?(rtml_action) tml = perform_rtml_action(rtml_action) return render_without_rtml_option(options.merge(:text => tml)) else raise Rtml::Errors::UnknownRtmlAction, "No RTML action responded to #{rtml_action}. RTML actions: #{rtml_actions.sort.to_sentence(:locale => :en)}", caller end end def perform_rtml_action(rtml_action) request.format = :rtml feigning_action(rtml_action) do rtml_helpers.fire_action(rtml_action) end force_rtml_format returning rtml_document.to_tml do |tml| if Rtml.configuration.log_tml Rails.logger.debug "(RTML: Response Headers: " + response.headers.inspect + ")" Rails.logger.debug tml end end end def feigning_action(name) action_name, self.action_name = self.action_name, name yield self.action_name = action_name end def force_rtml_format set_rtml_headers response.template.template_format = :rtml end def self.included(base) base.send(:alias_method_chain, :render, :rtml_option) base.send(:hide_action, :attempt_rtml_action, :perform_rtml_action, :feigning_action, :force_rtml_format) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rtml-2.0.4 | lib/rtml/controller/render_helpers.rb |