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

- old
+ new

@@ -1,13 +1,26 @@ require File.dirname(__FILE__)+'/mixins/erubis_capture_mixin' require File.dirname(__FILE__)+'/mixins/view_context_mixin' require File.dirname(__FILE__)+'/mixins/form_control_mixin' module Merb - PROTECTED_IVARS = %w[@cookies @session @headers @params - @env @in @status @root @method @request @fingerprint_before - @_new_cookie @tmpl_ext_cache @body] + PROTECTED_IVARS = %w[@_new_cookie + @method + @env + @body + @_fingerprint_before + @pager + @session + @headers + @page + @cookies + @request + @status + @_view_context_cache + @response + @params] + module GlobalHelper end # the ViewContext is really # just an empty container for us to fill with instance # variables from the controller, include helpers into @@ -17,10 +30,11 @@ include Merb::ViewContextMixin include Merb::FormControls include Merb::GlobalHelper def initialize(controller) + @_merb_partial_locals = {} @controller = controller (@controller.instance_variables - PROTECTED_IVARS).each do |ivar| self.instance_variable_set(ivar, @controller.instance_variable_get(ivar)) end begin @@ -41,17 +55,19 @@ end alias_method :old_respond_to?, :respond_to? def respond_to?(sym, include_private=false) - old_respond_to?(sym, include_private) || @controller.respond_to?(sym, include_private) + old_respond_to?(sym, include_private) || @controller.respond_to?(sym, include_private) || @_merb_partial_locals.key?(sym) end # catch any method calls that the controller responds to # and delegate them back to the controller. def method_missing(sym, *args, &blk) if @controller.respond_to? sym @controller.send(sym, *args, &blk) + elsif @_merb_partial_locals.key? sym + @_merb_partial_locals[sym] else super end end \ No newline at end of file