lib/rails-footnotes/notes/assigns_note.rb in rails3-footnotes-4.0.0.pre.4 vs lib/rails-footnotes/notes/assigns_note.rb in rails3-footnotes-4.0.0.pre.5

- old
+ new

@@ -1,70 +1,41 @@ require "#{File.dirname(__FILE__)}/abstract_note" module Footnotes module Notes class AssignsNote < AbstractNote - @@ignored_assigns = [ - :@action_has_layout, - :@before_filter_chain_aborted, - :@db_rt_after_render, - :@db_rt_before_render, - :@devise_mapping, - :@lookup_context, - :@performed_redirect, - :@performed_render, - :@real_format, - :@template, - :@url, - :@view_context_class, - :@_action_name, - :@_config, - :@_db_runtime, - :@_env, - :@_params, - :@_request, - :@_response, - :@_response_body, - :@_status, - :@_view_runtime, - ] - cattr_accessor :ignored_assigns, :instance_writter => false def initialize(controller) - @controller = controller + @assigns = controller.send(:view_assigns) end def title - "Assigns (#{assigns.size})" + "Assigns (#{assign_keys.size})" end def valid? - assigns + assign_keys.any? end def content rows = [] - assigns.each do |key| - rows << [ key, escape(assigned_value(key)) ] + assign_keys.each do |key| + rows << [ key, escape(@assigns[key].inspect) ] end mount_table(rows.unshift(['Name', 'Value']), :class => 'name_values', :summary => "Debug information for #{title}") end - protected + protected - def assigns - assign = [] - ignored = @@ignored_assigns + def assign_keys + @assign_keys ||= (@assigns.keys.reject{|k| k[0] == ?_ } - ignored_assigns) + end - @controller.instance_variables.each {|x| assign << x.intern } - @controller.protected_instance_variables.each {|x| ignored << x.intern } if @controller.respond_to? :protected_instance_variables + def ignored_assigns + [ "action_has_layout", + "lookup_context", + "view_context_class" ] + end - assign -= ignored - return assign - end - - def assigned_value(key) - @controller.instance_variable_get(key).inspect - end end end end