Module | Footnotes::Components |
In: |
lib/rails-footnotes/notes/components_note.rb
|
# File lib/rails-footnotes/notes/components_note.rb, line 44 def self.included(base) base.class_eval do alias_method_chain :add_footnotes!, :component Footnotes::Filter.notes.delete(:components) @@component_notes = [ :controller, :view, :params ] end end
# File lib/rails-footnotes/notes/components_note.rb, line 52 def add_footnotes_with_component! if component_request? initialize_component_notes! Footnotes::Filter.notes.unshift(*@notes) else add_footnotes_without_component! Footnotes::Filter.notes.delete_if {|note| note.class.to_s =~ /(ComponentNote)$/} end end
# File lib/rails-footnotes/notes/components_note.rb, line 63 def initialize_component_notes! @@component_notes.flatten.each do |note| begin note = eval("Footnotes::Notes::#{note.to_s.camelize}ComponentNote").new(@controller) if note.is_a?(Symbol) || note.is_a?(String) @notes << note if note.respond_to?(:valid?) && note.valid? rescue Exception => e # Discard note if it has a problem self.class.log_error("Footnotes #{note.to_s.camelize}ComponentNote Exception", e) next end end end