Sha256: c8d2976310d0ccce7a342ad70b20ffffe2c2c05afc2a4131a4b7bcfc469f9c73

Contents?: true

Size: 1.64 KB

Versions: 6

Compression:

Stored size: 1.64 KB

Contents

module Footnotes
  module Notes
    class AssignsNote < AbstractNote
      @@ignored_assigns = [
                            :@real_format,
                            :@before_filter_chain_aborted,
                            :@performed_redirect,
                            :@performed_render,
                            :@_params,
                            :@_response,
                            :@url,
                            :@template,
                            :@_request,
                            :@db_rt_before_render,
                            :@db_rt_after_render,
                            :@view_runtime
                          ]
      cattr_accessor :ignored_assigns, :instance_writter => false

      def initialize(controller)
        @controller = controller
      end

      def title
        "Assigns (#{assigns.size})"
      end

      def valid?
        assigns
      end

      def content
        rows = []
        assigns.each do |key|
          rows << [ key, escape(assigned_value(key)) ]
        end
        mount_table(rows.unshift(['Name', 'Value']), :class => 'name_values', :summary => "Debug information for #{title}")
      end

      protected

        def assigns
          assign = []
          ignored = @@ignored_assigns

          @controller.instance_variables.each {|x| assign << x.intern }
          @controller.protected_instance_variables.each {|x| ignored << x.intern } if @controller.respond_to? :protected_instance_variables

          assign -= ignored
          return assign
        end

        def assigned_value(key)
          @controller.instance_variable_get(key).inspect
        end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rails-footnotes-3.7.5.rc4 lib/rails-footnotes/notes/assigns_note.rb
rails-footnotes-3.7.5.rc3 lib/rails-footnotes/notes/assigns_note.rb
rails-footnotes-3.7.5.rc2 lib/rails-footnotes/notes/assigns_note.rb
rails-footnotes-3.7.5.rc1 lib/rails-footnotes/notes/assigns_note.rb
rails-footnotes-3.7.4 lib/rails-footnotes/notes/assigns_note.rb
rails-footnotes-3.7.3 lib/rails-footnotes/notes/assigns_note.rb