Skip to content

Commit

Permalink
Move controller ivar copying to a separate method
Browse files Browse the repository at this point in the history
  • Loading branch information
lifo committed Oct 5, 2008
1 parent 259a7a8 commit 4f53db0
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions actionpack/lib/action_view/base.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -290,21 +290,23 @@ def template_format
private private
attr_accessor :_first_render, :_last_render attr_accessor :_first_render, :_last_render


# Evaluate the local assigns and pushes them to the view. # Evaluates the local assigns and controller ivars, pushes them to the view.
def _evaluate_assigns_and_ivars #:nodoc: def _evaluate_assigns_and_ivars #:nodoc:
unless @assigns_added unless @assigns_added
@assigns.each { |key, value| instance_variable_set("@#{key}", value) } @assigns.each { |key, value| instance_variable_set("@#{key}", value) }

_copy_ivars_from_controller
if @controller
variables = @controller.instance_variable_names
variables -= @controller.protected_instance_variables if @controller.respond_to?(:protected_instance_variables)
variables.each { |name| instance_variable_set(name, @controller.instance_variable_get(name)) }
end

@assigns_added = true @assigns_added = true
end end
end end


def _copy_ivars_from_controller #:nodoc:
if @controller
variables = @controller.instance_variable_names
variables -= @controller.protected_instance_variables if @controller.respond_to?(:protected_instance_variables)
variables.each { |name| instance_variable_set(name, @controller.instance_variable_get(name)) }
end
end

def _set_controller_content_type(content_type) #:nodoc: def _set_controller_content_type(content_type) #:nodoc:
if controller.respond_to?(:response) if controller.respond_to?(:response)
controller.response.content_type ||= content_type controller.response.content_type ||= content_type
Expand Down

0 comments on commit 4f53db0

Please sign in to comment.