Class: Footnotes::Notes::PartialsNote
Class Method Summary
collapse
Instance Method Summary
collapse
close!, #escape, #has_fieldset?, #hash_to_xml_attributes, included?, #javascript, #legend, #link, #mount_table, #mount_table_for_hash, #onclick, #prefix?, #stylesheet, title, to_sym, #to_sym, #valid?
Constructor Details
#initialize(controller) ⇒ PartialsNote
Returns a new instance of PartialsNote.
15
16
17
|
# File 'lib/rails-footnotes/notes/partials_note.rb', line 15
def initialize(controller)
@controller = controller
end
|
Class Method Details
.start!(controller) ⇒ Object
7
8
9
10
11
12
13
|
# File 'lib/rails-footnotes/notes/partials_note.rb', line 7
def self.start!(controller)
self.partials = []
@subscriber ||= ActiveSupport::Notifications.subscribe('render_partial.action_view') do |*args|
event = ActiveSupport::Notifications::Event.new *args
self.partials << {:file => event.payload[:identifier], :duration => event.duration}
end
end
|
Instance Method Details
#content ⇒ Object
27
28
29
30
31
32
33
34
|
# File 'lib/rails-footnotes/notes/partials_note.rb', line 27
def content
rows = self.class.partials.map do |partial|
href = Footnotes::Filter.prefix(partial[:file],1,1)
shortened_name = partial[:file].gsub(File.join(Rails.root,"app/views/"),"")
[%{<a href="#{href}">#{shortened_name}</a>},"#{partial[:duration]}ms"]
end
mount_table(rows.unshift(%w(Partial Time)), :summary => "Partials for #{title}")
end
|
#row ⇒ Object
19
20
21
|
# File 'lib/rails-footnotes/notes/partials_note.rb', line 19
def row
:edit
end
|
#title ⇒ Object
23
24
25
|
# File 'lib/rails-footnotes/notes/partials_note.rb', line 23
def title
"Partials (#{partials.size})"
end
|