Module: Rtml::Controller::RenderHelpers
- Defined in:
- lib/rtml/controller/render_helpers.rb
Class Method Summary collapse
Instance Method Summary collapse
- #attempt_rtml_action(rtml_action, options = {}) ⇒ Object
- #feigning_action(name) ⇒ Object
- #force_rtml_format ⇒ Object
- #perform_rtml_action(rtml_action) ⇒ Object
- #render_with_rtml_option(options = nil, extra_options = {}, &block) ⇒ Object
Class Method Details
.included(base) ⇒ Object
49 50 51 52 |
# File 'lib/rtml/controller/render_helpers.rb', line 49 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 |
Instance Method Details
#attempt_rtml_action(rtml_action, options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rtml/controller/render_helpers.rb', line 12 def attempt_rtml_action(rtml_action, = {}) if rtml_helpers.respond_to?(rtml_action) tml = perform_rtml_action(rtml_action) return render_without_rtml_option(.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 |
#feigning_action(name) ⇒ Object
38 39 40 41 42 |
# File 'lib/rtml/controller/render_helpers.rb', line 38 def feigning_action(name) action_name, self.action_name = self.action_name, name yield self.action_name = action_name end |
#force_rtml_format ⇒ Object
44 45 46 47 |
# File 'lib/rtml/controller/render_helpers.rb', line 44 def force_rtml_format set_rtml_headers response.template.template_format = :rtml end |
#perform_rtml_action(rtml_action) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rtml/controller/render_helpers.rb', line 23 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 |
#render_with_rtml_option(options = nil, extra_options = {}, &block) ⇒ Object
2 3 4 5 6 7 8 9 10 |
# File 'lib/rtml/controller/render_helpers.rb', line 2 def render_with_rtml_option( = nil, = {}, &block) if ( = ).is_a?(Hash) || ( = ).is_a?(Hash) = if !.key?(:rtml) && .is_a?(Hash) if rtml_action = .delete(:rtml) return attempt_rtml_action(rtml_action) end end render_without_rtml_option(, , &block) end |