Class: Footnotes::Notes::QuerySubscriber
- Inherits:
-
ActiveSupport::LogSubscriber
- Object
- ActiveSupport::LogSubscriber
- Footnotes::Notes::QuerySubscriber
- Defined in:
- lib/rails-footnotes/notes/queries_note.rb
Instance Attribute Summary collapse
-
#events ⇒ Object
Returns the value of attribute events.
-
#ignore_regexps ⇒ Object
Returns the value of attribute ignore_regexps.
Instance Method Summary collapse
-
#initialize(orm) ⇒ QuerySubscriber
constructor
A new instance of QuerySubscriber.
- #reset! ⇒ Object
- #sql(event) ⇒ Object
Constructor Details
#initialize(orm) ⇒ QuerySubscriber
Returns a new instance of QuerySubscriber.
98 99 100 101 |
# File 'lib/rails-footnotes/notes/queries_note.rb', line 98 def initialize(orm) @events = [] orm.each {|adapter| ActiveSupport::LogSubscriber.attach_to adapter, self} end |
Instance Attribute Details
#events ⇒ Object
Returns the value of attribute events.
96 97 98 |
# File 'lib/rails-footnotes/notes/queries_note.rb', line 96 def events @events end |
#ignore_regexps ⇒ Object
Returns the value of attribute ignore_regexps.
96 97 98 |
# File 'lib/rails-footnotes/notes/queries_note.rb', line 96 def ignore_regexps @ignore_regexps end |
Instance Method Details
#reset! ⇒ Object
103 104 105 |
# File 'lib/rails-footnotes/notes/queries_note.rb', line 103 def reset! self.events.clear end |
#sql(event) ⇒ Object
107 108 109 110 111 |
# File 'lib/rails-footnotes/notes/queries_note.rb', line 107 def sql(event) unless QueriesNote.ignored_regexps.any? {|rex| event.payload[:sql] =~ rex } @events << QuerySubscriberNotifactionEvent.new(event.dup, caller) end end |