Sha256: f560c3c3df580f9e754d7a08dab6df1d7aacc663c0d79c7514ea2db2914a683a

Contents?: true

Size: 887 Bytes

Versions: 6

Compression:

Stored size: 887 Bytes

Contents

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

module Footnotes
  module Notes
    class AssignsNote < AbstractNote

      def initialize(controller)
        @assigns = controller.send(:view_assigns)
      end

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

      def valid?
        assign_keys.any?
      end

      def content
        rows = []
        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

      def assign_keys
        @assign_keys ||= (@assigns.keys.reject{|k| k[0] == ?_ } - ignored_assigns)
      end

      def ignored_assigns
        [ "action_has_layout",
          "lookup_context",
          "view_context_class" ]
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rails3-footnotes-4.0.0.pre.10 lib/rails-footnotes/notes/assigns_note.rb
rails3-footnotes-4.0.0.pre.9 lib/rails-footnotes/notes/assigns_note.rb
rails3-footnotes-4.0.0.pre.8 lib/rails-footnotes/notes/assigns_note.rb
rails3-footnotes-4.0.0.pre.7 lib/rails-footnotes/notes/assigns_note.rb
rails3-footnotes-4.0.0.pre.6 lib/rails-footnotes/notes/assigns_note.rb
rails3-footnotes-4.0.0.pre.5 lib/rails-footnotes/notes/assigns_note.rb