Changeset 512
- Timestamp:
- 09/04/07 19:20:32 (1 year ago)
- Files:
-
- trunk/lib/merb/view_context.rb (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/merb/view_context.rb
r469 r512 5 5 @method 6 6 @env 7 @ controller7 @web_controller 8 8 @_body 9 9 @_fingerprint_before … … 27 27 include Merb::FormControls 28 28 include Merb::GlobalHelper 29 include Merb::WebControllerMixin 29 30 30 31 def initialize(controller) 31 32 @_merb_partial_locals = {} 32 @ controller = controller33 (@ controller.instance_variables - PROTECTED_IVARS).each do |ivar|34 self.instance_variable_set(ivar, @ controller.instance_variable_get(ivar))33 @web_controller = controller 34 (@web_controller.instance_variables - PROTECTED_IVARS).each do |ivar| 35 self.instance_variable_set(ivar, @web_controller.instance_variable_get(ivar)) 35 36 end 36 37 begin 37 self.class.class_eval("include Merb::#{@ controller.class.name}Helper")38 self.class.class_eval("include Merb::#{@web_controller.class.name}Helper") 38 39 rescue NameError 39 MERB_LOGGER.debug("Missing Helper: Merb::#{@ controller.class.name}Helper")40 MERB_LOGGER.debug("Missing Helper: Merb::#{@web_controller.class.name}Helper") 40 41 end 41 42 end … … 46 47 end 47 48 48 # accessor for the view. refers to the current @ controller object49 # accessor for the view. refers to the current @web_controller object 49 50 def controller 50 @ controller51 @web_controller 51 52 end 52 53 def request 54 @controller.request 55 end 56 57 def params 58 @controller.params 59 end 60 61 def cookies 62 @controller.cookies 63 end 64 65 def headers 66 @controller.headers 67 end 68 69 def session 70 @controller.session 71 end 72 73 def response 74 @controller.response 75 end 76 53 77 54 alias_method :old_respond_to?, :respond_to? 78 55 79 56 def respond_to?(sym, include_private=false) 80 old_respond_to?(sym, include_private) || @ controller.respond_to?(sym, include_private) || @_merb_partial_locals.key?(sym)57 old_respond_to?(sym, include_private) || @web_controller.respond_to?(sym, include_private) || @_merb_partial_locals.key?(sym) 81 58 end 82 59 … … 84 61 # and delegate them back to the controller. 85 62 def method_missing(sym, *args, &blk) 86 if @ controller.respond_to? sym87 @ controller.send(sym, *args, &blk)63 if @web_controller.respond_to? sym 64 @web_controller.send(sym, *args, &blk) 88 65 elsif @_merb_partial_locals.key? sym 89 66 @_merb_partial_locals[sym]
