Class: Footnotes::Notes::QuerySubscriber

Inherits:
ActiveSupport::LogSubscriber
  • Object
show all
Defined in:
lib/rails-footnotes/notes/queries_note.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(orm) ⇒ QuerySubscriber

Returns a new instance of QuerySubscriber.



105
106
107
108
109
# File 'lib/rails-footnotes/notes/queries_note.rb', line 105

def initialize(orm)
  super() 
  @events = []
  orm.each {|adapter| ActiveSupport::LogSubscriber.attach_to adapter, self}
end

Instance Attribute Details

#eventsObject

Returns the value of attribute events.



103
104
105
# File 'lib/rails-footnotes/notes/queries_note.rb', line 103

def events
  @events
end

#ignore_regexpsObject

Returns the value of attribute ignore_regexps.



103
104
105
# File 'lib/rails-footnotes/notes/queries_note.rb', line 103

def ignore_regexps
  @ignore_regexps
end

Instance Method Details

#reset!Object



111
112
113
# File 'lib/rails-footnotes/notes/queries_note.rb', line 111

def reset!
  self.events.clear
end

#sql(event) ⇒ Object



115
116
117
118
119
# File 'lib/rails-footnotes/notes/queries_note.rb', line 115

def sql(event)
  unless QueriesNote.ignored_regexps.any? {|rex| event.payload[:sql] =~ rex }
    @events << QuerySubscriberNotifactionEvent.new(event.dup, caller)
  end
end