lib/rtml/controller/document_generator.rb in rtml-2.0.3 vs lib/rtml/controller/document_generator.rb in rtml-2.0.4

- old
+ new

@@ -38,17 +38,26 @@ def respond_to?(name, *args, &block) return super || rtml_document.respond_to?(name, *args, &block) end def method_missing(name, *args, &block) + rtml_document.copy_ivars_from(self) rtml_document.send(name, *args, &block) rescue raise $!, $!.message, caller end + def fire_action(action_name) + copy_ivars_from(controller) + # Give rtml actions access to the controller's view helpers + (class << self; self; end).send(:include, controller.response.template.helpers) + __send__(action_name) + end + def copy_ivars_from(source) ivars = source.instance_variables ivars -= source.protected_instance_variables if source.respond_to?(:protected_instance_variables) + ivars -= source.rtml_protected_instance_variables if source.respond_to?(:rtml_protected_instance_variables) ivars.each { |ivar| instance_variable_set(ivar, source.instance_variable_get(ivar)) } rtml_document.copy_ivars_from(self) end hide_action :initialize, :method_missing, :respond_to?, :copy_ivars_from \ No newline at end of file