Class: Footnotes::Notes::ViewNote

Inherits:
AbstractNote show all
Defined in:
lib/rails-footnotes/notes/view_note.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractNote

close!, #escape, #has_fieldset?, #hash_to_xml_attributes, included?, #javascript, #legend, #mount_table, #mount_table_for_hash, #onclick, #prefix?, #stylesheet, title, to_sym, #to_sym

Constructor Details

#initialize(controller) ⇒ ViewNote

Returns a new instance of ViewNote.



13
14
15
# File 'lib/rails-footnotes/notes/view_note.rb', line 13

def initialize(controller)
  @controller = controller
end

Class Method Details

.start!(controller) ⇒ Object



6
7
8
9
10
11
# File 'lib/rails-footnotes/notes/view_note.rb', line 6

def self.start!(controller)
  @subscriber ||= ActiveSupport::Notifications.subscribe('render_template.action_view') do |*args|
    event = ActiveSupport::Notifications::Event.new *args
    self.template = {:file => event.payload[:identifier], :duration => event.duration}
  end
end

Instance Method Details



25
26
27
# File 'lib/rails-footnotes/notes/view_note.rb', line 25

def link
  escape(Footnotes::Filter.prefix(filename, 1, 1))
end

#rowObject



17
18
19
# File 'lib/rails-footnotes/notes/view_note.rb', line 17

def row
  :edit
end

#titleObject



21
22
23
# File 'lib/rails-footnotes/notes/view_note.rb', line 21

def title
  "View (#{"%.3f" % self.template[:duration]}ms)"
end

#valid?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/rails-footnotes/notes/view_note.rb', line 29

def valid?
  prefix? && filename && File.exists?(filename)
end