Class: Chillout::ListenerInjector

Inherits:
Object
  • Object
show all
Defined in:
lib/chillout/listener_injector.rb

Constant Summary collapse

LISTENERS =
[:active_record]

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#loggerObject

Returns the value of attribute logger.



3
4
5
# File 'lib/chillout/listener_injector.rb', line 3

def logger
  @logger
end

Instance Method Details

#active_record_injectorObject



14
15
16
17
18
19
20
21
# File 'lib/chillout/listener_injector.rb', line 14

def active_record_injector
  if defined?(ActiveRecord)
    ActiveRecord::Base.extend(ActiveRecordCreationListener)
    return true
  end

  return false
end

#inject!Object



7
8
9
10
11
12
# File 'lib/chillout/listener_injector.rb', line 7

def inject!
  LISTENERS.each do |listener|
    listener_injection = send("#{listener}_injector") 
    logger.info "[Chillout] Injected #{listener} listener" if listener_injection == true
  end            
end