Sha256: 102438739c7897ae57ab6df18b938a5cc982354d15eeea5dc8cd64612924f70e

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

require "#{File.dirname(__FILE__)}/abstract_note"

module Footnotes
  module Notes
    class AssignsNote < AbstractNote
      @@ignored_assigns = %w( @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, assigned_value(key) ]
        end
        mount_table(rows.unshift(['Name', 'Value']), :class => 'name_values', :summary => "Debug information for #{title}")
      end

      protected

        def assigns
          return @assigns if @assigns

          @assigns = @controller.instance_variables
          @assigns -= @controller.protected_instance_variables if @controller.respond_to? :protected_instance_variables
          @assigns -= ignored_assigns
        end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails-footnotes-3.6.6 lib/rails-footnotes/notes/assigns_note.rb