Class: Ocelot::Watcher

Inherits:
Object
  • Object
show all
Defined in:
lib/ocelot/processor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeWatcher

Returns a new instance of Watcher.



11
12
13
14
# File 'lib/ocelot/processor.rb', line 11

def initialize
  @last = Time.now
  @mutex = Mutex.new
end

Instance Attribute Details

#associationObject

Returns the value of attribute association.



4
5
6
# File 'lib/ocelot/processor.rb', line 4

def association
  @association
end

#lastObject (readonly)

Returns the value of attribute last.



8
9
10
# File 'lib/ocelot/processor.rb', line 8

def last
  @last
end

#lineObject

Returns the value of attribute line.



6
7
8
# File 'lib/ocelot/processor.rb', line 6

def line
  @line
end

#objObject

Returns the value of attribute obj.



9
10
11
# File 'lib/ocelot/processor.rb', line 9

def obj
  @obj
end

#opObject

Returns the value of attribute op.



3
4
5
# File 'lib/ocelot/processor.rb', line 3

def op
  @op
end

#ruleObject

Returns the value of attribute rule.



7
8
9
# File 'lib/ocelot/processor.rb', line 7

def rule
  @rule
end

#sqlObject

Returns the value of attribute sql.



5
6
7
# File 'lib/ocelot/processor.rb', line 5

def sql
  @sql
end

Instance Method Details

#pingObject



20
21
22
23
24
# File 'lib/ocelot/processor.rb', line 20

def ping
  sync do |w|
    "Might be stuck processing #{w.obj}#{w.association.nil? ? "" : "."}#{w.association} at #{w.line} using #{w.rule}, may be exec'ing #{ActiveRecord::Base.connection.last_query}" if Time.now - w.last > 20
  end
end

#syncObject



26
27
28
29
30
# File 'lib/ocelot/processor.rb', line 26

def sync
  @mutex.synchronize do
    yield self
  end
end

#trace(event, file, line, id, binding, clazz) ⇒ Object



32
33
34
35
36
37
# File 'lib/ocelot/processor.rb', line 32

def trace(event, file, line, id, binding, clazz)
  if clazz == Ocelot::Processor
    @last = Time.now
    @line = line
  end    
end